Skip to content

Commit 8073d7c

Browse files
committed
fix: handle duplicate SVG images
1 parent a1fea7e commit 8073d7c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/swift-zebras-relax.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: handle duplicate SVG images

packages/enhanced-img/src/preprocessor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function image(opts) {
111111
const metadata = await sharp(resolved_id).metadata();
112112
// this must come after the await so that we don't hand off processing between getting
113113
// the imports.size and incrementing the imports.size
114-
const name = '__IMPORTED_ASSET_' + imports.size + '__';
114+
const name = imports.get(original_url) || '__IMPORTED_ASSET_' + imports.size + '__';
115115
const new_markup = `<img ${serialize_img_attributes(content, node.attributes, {
116116
src: `{${name}}`,
117117
width: metadata.width || 0,

0 commit comments

Comments
 (0)