How does unlazy handle retina displays? #12
-
Hi, I was wondering how unlazy handles the <img
loading="lazy"
src="data:image/svg+xml, ..."
data-srcset="
image-320w.jpg 320w,
image-640w.jpg 640w,
image-1280-retina.jpg 1280w
"
data-sizes="auto"
> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi there! The As for the retina display images, if you want to provide a 2x version for the retina display, you should include that in your The |
Beta Was this translation helpful? Give feedback.
Hi there!
The
data-sizes="auto"
feature is generally used to dynamically adjust thesizes
attribute of your<img>
element based on its display size: it updates thesizes
attribute to theoffsetWidth
of the<img>
element.As for the retina display images, if you want to provide a 2x version for the retina display, you should include that in your
data-srcset
attribute, and the browser will select the appropriate image based on the device's pixel ratio and the image's declared width.In your case, it looks like you're providing 3 different image widths (320, 640, and 1280 pixels). If a device with a pixel ratio of 2 was to display the image at a size of 640 pixels wide, it would ideally sele…