diff --git a/src/vite-plugin.js b/src/vite-plugin.js
index c8ccb26b3f17cb69eb1e725bab1cde02c88c36cf..565ec235170b148017d191c62599c3968457e77e 100644
--- a/src/vite-plugin.js
+++ b/src/vite-plugin.js
@@ -114,7 +114,7 @@ export function image_plugin(imagetools_plugin) {
const image = await process_id(resolved_id, plugin_context, imagetools_plugin);
s.update(node.start, node.end, img_to_picture(content, node, image));
} else {
- const metadata = await sharp(resolved_id).metadata();
+ const metadata = await sharp(resolved_id, { animated: true }).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 = imports.get(original_url) || '__IMPORTED_ASSET_' + imports.size + '__';
@@ -136,7 +136,7 @@ export function image_plugin(imagetools_plugin) {
*/
const pending_ast_updates = [];
- walk(/** @type {import('svelte/compiler').AST.TemplateNode} */ (ast), null, {
+ walk(/** @type {import('svelte/compiler').AST.TemplateNode} */(ast), null, {
RegularElement(node, { next }) {
if ('name' in node && node.name === 'enhanced:img') {
// Compare node tag match
@@ -231,7 +231,7 @@ export function parse_object(str) {
function get_attr_value(node, attr) {
if (!('type' in node) || !('attributes' in node)) return;
const attribute = node.attributes.find(
- /** @param {any} v */ (v) => v.type === 'Attribute' && v.name === attr
+ /** @param {any} v */(v) => v.type === 'Attribute' && v.name === attr
);
if (!attribute || !('value' in attribute) || typeof attribute.value === 'boolean') return;
@@ -376,8 +376,8 @@ function dynamic_img_to_picture(content, node, src_var_name) {
{${src_var_name}} was not enhanced. Cannot determine dimensions.
{:else}
+ src: `{${src_var_name}}`
+ })} />
{/if}
{:else}
@@ -385,10 +385,10 @@ function dynamic_img_to_picture(content, node, src_var_name) {
{/each}
+ src: `{${src_var_name}.img.src}`,
+ width: `{${src_var_name}.img.w}`,
+ height: `{${src_var_name}.img.h}`
+ })} />
{/if}`;
}