Skip to content

Commit b80cd4c

Browse files
authored
fix: properly handle multiple SVGs (#13127)
1 parent c89805e commit b80cd4c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/gentle-queens-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/enhanced-img': patch
3+
---
4+
5+
fix: properly handle multiple SVGs

packages/enhanced-img/src/preprocessor.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ export function image(opts) {
108108
}
109109
s.update(node.start, node.end, img_to_picture(content, node, image));
110110
} else {
111-
const name = '__IMPORTED_ASSET_' + imports.size + '__';
112111
const metadata = await sharp(resolved_id).metadata();
112+
// this must come after the await so that we don't hand off processing between getting
113+
// the imports.size and incrementing the imports.size
114+
const name = '__IMPORTED_ASSET_' + imports.size + '__';
113115
const new_markup = `<img ${serialize_img_attributes(content, node.attributes, {
114116
src: `{${name}}`,
115117
width: metadata.width || 0,

0 commit comments

Comments
 (0)