WICG / responsive-image-client-hints

A spec for a suite of client hints, useful for content negotiation for responsive images
https://wicg.github.io/responsive-image-client-hints
Other
7 stars 9 forks source link

Servers can't set resolution on images requested with only `Sec-CH-Width` #3

Open eeeps opened 4 years ago

eeeps commented 4 years ago

Servers can only intelligently set a response’s resolution, if they are adapting to fit a Width hint, if they also have a DPR hint. For instance, let's say an author wrote the following markup on a page configured to send just the Width hint:

<img src="a.jpg" sizes="33vw" />

On a 2x device/1000px-wide viewport, this might generate a request like:

GET a.jpg
Sec-CH-Width: 660

This doesn't give the server enough information to set a resolution on the response. The least-worst thing a server can do here, I think, is send a 660-pixel-wide, 1x resource, which will have a density-corrected intrinsic width of 660px, instead of 330px.

If there's an extrinsic size on the image, this isn't a problem, but if there isn't, the image will be too big, and blurry.

Two options spring to mind:

  1. Revert Width to be defined in terms of CSS px (or, more likely, deprecate it and mint something new). This way Width-only images will have the correct layout width, even if they're the wrong resolution. This makes more sense to me as an author – I did supply the server with the Width; I didn't supply the server with the DPR. It makes sense that adding DPR fixes the DPR problem.
  2. Having some sort of authoring requirement to enable DPR whenever Width is enabled. And maybe a console warning or something.
eeeps commented 3 years ago

Perhaps servers shouldn't be in charge of setting image resolution / layout dimensions.

  1. If https://github.com/whatwg/html/issues/3981 happened, the sizes attribute (that generated the Sec-CH-Width value) would be in charge of setting the intrinsic width.
  2. If servers had some guarantee that the image would be extrinsically sized by the author, the intrinsic size doesn't matter.