Skip to content

Commit

Permalink
fix: properly handle multiple SVGs (#13127)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Dec 9, 2024
1 parent c89805e commit b80cd4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gentle-queens-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/enhanced-img': patch
---

fix: properly handle multiple SVGs
4 changes: 3 additions & 1 deletion packages/enhanced-img/src/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ export function image(opts) {
}
s.update(node.start, node.end, img_to_picture(content, node, image));
} else {
const name = '__IMPORTED_ASSET_' + imports.size + '__';
const metadata = await sharp(resolved_id).metadata();
// this must come after the await so that we don't hand off processing between getting
// the imports.size and incrementing the imports.size
const name = '__IMPORTED_ASSET_' + imports.size + '__';
const new_markup = `<img ${serialize_img_attributes(content, node.attributes, {
src: `{${name}}`,
width: metadata.width || 0,
Expand Down

0 comments on commit b80cd4c

Please sign in to comment.