Open vladshcherbin opened 7 months ago
Reproduction created - https://github.com/vladshcherbin/svelte-lab
Can be run with standard pnpm dev
(or other package manager)
You may have to add a w
query parameter for sizes smaller than 540px.
The smallest picture generated automatically will have a width of 540px. If you'd like smaller images or would otherwise like to specify custom widths, you can do that with the w query parameter:
see https://kit.svelte.dev/docs/images#sveltejs-enhanced-img-srcset-and-sizes
It does seem like a bug if the srcset is different between an inline src and an imported src
@eltigerchino yes, but sizes like 540px are never generated
I've debugged to directives, on line 76
qs.get('imgSizes')
is supposed to have sizes
from img
tag but it's empty for ?enhanced
imports.
Imports:
'$lib/assets/images/boston-overview.jpg?enhanced'
- qs.get('imgSizes')
is empty, even though <enhanced:img ... sizes />
has it
'$lib/assets/images/boston-overview.jpg?enhanced&imgSizes="(width >= 700px) 500px, 100px"'
- qs.get('imgSizes')
is populated correctly and 540px and other sizes are generated
The remaining part is to find why imgSizes
is not populated from img
tag 🕵️♂️🐛
@benmccann can you please take a quick look, maybe there is a quick fix? I've tried to figure out with no luck 🍀
I'm also experiencing this same bug, temporary fix being to explicitly define the src.
Not sure how relevant that is, but even if passed imgSizes
in query, it seems to be straight up ignored in enhanced:img
Describe the bug
Hey 👋
I can't figure out how to dynamically enhance images properly. I've added
?enhanced
part and images are processed into different formats. However,srcset
has only 2 variants:Images have different formats but
srcset
with 2 variants:When importing same file directly with a path, images with multiple
srcset
are created:Same image a lot more
srcset
variants:What can be the reason?
I'd love to have the second variant but for
?enhanced
images. Tried importing using various variants from https://github.com/sveltejs/kit/issues/11535 with no luck.Reproduction
https://github.com/vladshcherbin/svelte-lab
Can be run with standard
pnpm dev
(or other package manager)Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response