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

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

Open
eeeps opened this issue Aug 5, 2020 · 1 comment
Open

Comments

@eeeps
Copy link
Collaborator

eeeps commented Aug 5, 2020

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
Copy link
Collaborator Author

eeeps commented Jul 26, 2021

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

  1. If sizes attribute should directly set the intrinsic width of the image whatwg/html#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.

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

1 participant