intrinsicsize-attribute
intrinsicsize-attribute copied to clipboard
intrinsicsize + the `Width` Client Hint
Use case: when sending the Width Client Hint, I want to be able to specify aspect-ratios instead of sizes, just as I can with srcset, as discussed in #3. e.g.:
<img src="variable-width.jpg" sizes="25vw" intrinsicsize="16x9" />
[✂️ edit! I worked through a whole example from a false premise! doh! ✂️]
Naively, seems like you should just be able to apply the intrinsic ratio from intrinsicsize to the sizes width to get a density-corrected intrinsic height. But, given that sizes only ends up setting the density-corrected intrinsic width of the image as a side effect, and in conjunction with w descriptors... how could this work?
cc: @yoavweiss @igrigorik @colinbendell
Width doesn't want to have anything whatsoever to do with sizes; that's the displayed width on the page. Width is asking for an image with a particular pixel width, aka the w value, assuming I'm reading the spec correctly.
Assuming that w and intrinsicsize are both used, you can then infer a desired pixel height and send that along in a future CH, yes.
Width doesn't want to have anything whatsoever to do with sizes
Chrome doesn’t send Width unless it has a sizes to calculate it from. It attaches Width = the sizes width × window.devicePixelRatio, to requests.
Assuming that w and intrinsicsize are both used, you can then infer a desired pixel height and send that along in a future CH
Client Hints are meant to be used instead of srcset (and xs and ws), not in conjunction with it.
Chrome doesn’t send Width unless it has a sizes to calculate it from. It attaches Width = the sizes width × window.devicePixelRatio, to requests.
Ah, ok. This derivation of the Width value isn't explained anywhere in the spec, so I wasn't aware.
Anyway, I'm also coming to believe we need to attach more intrinsic importance to sizes here - sizes+w happens to result in an image with a naturalWidth matching sizes if the w descriptor accurately matches the image. If it doesn't, then the density we determine is off, and the resulting naturalWidth (determined from the resource's actual size, divided by density) doesn't match sizes.
So sizes probably should be interpreted as actually setting the intrinsic width of the image. Has this accidentally slipped into the spec anywhere? With this, we can go ahead and assume that sizes expresses some useful information, even if the w descriptor isn't being used.