Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no support for pixel density descriptor (e.g. 2x)? #15

Open
larsbo opened this issue May 8, 2017 · 2 comments
Open

no support for pixel density descriptor (e.g. 2x)? #15

larsbo opened this issue May 8, 2017 · 2 comments

Comments

@larsbo
Copy link

larsbo commented May 8, 2017

When a srcset image is specified with a pixel density descriptor instead of a width descriptor as explained here:
https://webkit.org/blog/2910/improved-support-for-high-resolution-displays-with-the-srcset-image-attribute/
or more detailed in the official spec:
https://html.spec.whatwg.org/multipage/embedded-content.html#width-descriptor
the higher resolution image will be removed from srcset.

For example something like this

<img class="responsively-lazy" [...] data-srcset="image/3945799cca93f17f_280x280.jpg, image/[email protected] 2x">

will be transformed into this

<img class="responsively-lazy" [...] srcset="image/3945799cca93f17f_280x280.jpg">
@ivopetkov
Copy link
Owner

That's true. Instead, the library takes pixel density into account.
Here is an example:
< ... data-srcset="images/400.jpg 400w, images/800.jpg 800w, images/1000.jpg 1000w" ... >
If the image is viewed on 2x device and the image width is 400px, then the 800w version will be loaded (2x400=800). If the device is 2.5x then the 1000w version will be loaded (2.5x400=1000).
This makes describing images much easier.

@larsbo
Copy link
Author

larsbo commented May 9, 2017

What about a situation where you don't know images sizes, container widths etc. and you have only two image versions - a small one and a 2x-version and just want to automatically display the large one at high density displays?
For this case the other spec definition would make more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants