Skip to content

Commit

Permalink
fix(plugin): improved dimension query
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Sep 13, 2024
1 parent f8b6b58 commit 819c4d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tmpl/plugin.tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ async function getImageSize (src) {
if (!dimensionCache.has(src)) {
const { width, height } = await new Promise((resolve) => {
const img = new global.Image();
img.onload = () => resolve({width: img.naturalWidth, height: img.naturalHeight});
let img = new global.Image();
img.onload = () => {
const dimension = { width: img.naturalWidth, height: img.naturalHeight };
img = null;
resolve(dimension)
};
img.src = src;
});
dimensionCache.set(src, { width, height });
Expand Down

0 comments on commit 819c4d0

Please sign in to comment.