Skip to content

Commit

Permalink
fix: handle duplicate SVG images
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Dec 12, 2024
1 parent a1fea7e commit 8073d7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/swift-zebras-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/enhanced-img': patch
---

fix: handle duplicate SVG images
2 changes: 1 addition & 1 deletion packages/enhanced-img/src/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function image(opts) {
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 name = imports.get(original_url) || '__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 8073d7c

Please sign in to comment.