-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Clarification] px
in sizes
in relation to pixel density
#7580
Comments
Can you provide some example source code to illustrate exactly what you're having a problem with? |
I'm not able to reproduce what you described -- with this demo, with http://software.hixie.ch/utilities/js/live-dom-viewer/saved/10026
|
Note that browsers are free to decide how they choose a candidate from Here's the current logic in chromium: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/parser/html_srcset_parser.cc;l=423 |
Could it be an issue/missing implementation in the mobile emulation of Chrome Dev tools? See this minimal example:
|
Yeah, it's possible the emulated DPR in devtools isn't honored by I found this issue, not sure if it's the same: https://bugs.chromium.org/p/chromium/issues/detail?id=1131815 cc @mathiasbynens (edit: hmm it seems to be a feature request) |
I believe this isn't an issue with the spec, so closing. |
@zcorpan: So it works correctly in native browsers, just not in Dev tools? Then this is a dev tools/mobile emulator bug in Chrome. |
Yeah, at least I couldn't get the image to change to the smaller one (with It responds to page zoom: View -> zoom out, then reload with devtools open (with |
@zcorpan: Yes, I can confirm that it works on native Chrome but not on Chrome Dev Tools Mobile emulator. As you recommended I will report this issue as a new bug in the mobile emulator of Chrome Dev Tools. |
@zcorpan: I created a new issue for Chrome/Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1294293 |
In some cases the img
sizes
attribute value may be specified in pixels (px
). For example, under a specific breakpoint/media query the image element may have a static width.During manual browser testing I noticed that the absolute width in pixels used in
sizes
is not interpreted as CSS pixels (1x density), but rather as absolute pixels.The browser will pick an image source that is always closest or equal to that given width of pixels, regardless of pixel density.
That means that e.g a
100px
sizes
will result in a100px
image source for a1x
dpi screen,2x
dpi screen,3x
dpi screen and so on, and not in a200px
image source for a2x
dpi screen and a300px
image source for a3x
dpi screen.Is this behavior intended? So for a static
sizes
inpx
extra media queries would need to be used, one for each possible pixel density with its own pre-multiplied pixel value, beyond the standard1x
?The text was updated successfully, but these errors were encountered: