Skip to content

Commit

Permalink
feat: add ratio option to set w/h
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Jan 10, 2023
1 parent a0a56c3 commit e6995fb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ docs/.vitepress/cache
docs/.vitepress/dist
.github
**/*.json5
example/dist
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mock Server Example</title>
<title>Image Placeholder Example</title>
</head>
<body>
<div class="img"></div>
Expand Down
2 changes: 1 addition & 1 deletion src/pathToImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function pathToImage(
const query = urlQuery as ImagePlaceholderQuery
const imgType = params.type || DEFAULT_PARAMS.type!
const width = Number(params.width) || 300
const height = Number(params.height) || Math.ceil((width / 16) * 9)
const height = Number(params.height) || Math.ceil(width * options.ratio)

const createOptions: CreateOptions = {
width,
Expand Down
1 change: 1 addition & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const parseOptions = (
type: 'png',
quality: 80,
compressionLevel: 6,
ratio: 9 / 16,
inline: false,
} as ImagePlaceholderOptions,
options,
Expand Down

0 comments on commit e6995fb

Please sign in to comment.