Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly handle multiple SVGs #13127

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading