I did not know what the data-sizes="auto"
exactly does until now, but I think I got it now.
First: It does not create new image sizes. If you load the example page from lazysizes without JavaScript, the image sizes are linked in the code, too (so no on-the-fly image generation).
Second: The auto
value for data-sizes
is great because it sets the value of sizes
to the exact width of the image when it is loaded, so the browser gets the perfect value (from sizes
) to decide what image from srcset
he should load for the user.
How you can test if that works:
- Load a page with
data-sizes="auto"
attributes.
- Scroll until they get loaded
- Check the
sizes
attribute value of the image with the developer tools of your browser
If it says the specific width of the image (for example, 945px), it works ??
I hope that was understandable.
I will set the integration of the data-sizes="auto"
on my list as a optional feature for a future version of the plugin, as it seems to be a great functionality. So thanks for the hint ??
Best regards,
Florian