-
Notifications
You must be signed in to change notification settings - Fork 35
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
API for getting/setting image pixel density #252
Comments
Yeah, I don't see anything wrong with the idea, and being able to set the default densities of things seems useful. Are you just asking for the sizing algo to check this header on the response and respond accordingly? |
Yes, I guess there are two different things here, although they are related in terms of API surface...
|
Just Curious to know. In the case of offline, Will it returns the image from cache and scales it automatically or wont render the image from cache?. |
Presumably we'd have to cache its server-specified resolution along with it. Then it'd scale automatically. |
HTTP response headers are cached (we need them for Accept+Vary processing, ETags, etc), so that's not an issue, the value will be available when coming from cache. |
bump ... any blockers for making this happen? |
It's not clear to me that Client-Hints will be adopted by all browsers. I would recommend monkey-patching HTML in the CH spec for the header part for now. The JS API can be added, but I don't know what behavior you would like it to have. Should the default be a special "auto" value that has today's behavior, and if you set it to a number, that number gets used even if a new resource is selected? Or something else? |
@zcorpan monkey patch HTML spec from an IETF doc? Yikes.. If anything, I think it would make sense to do the reverse: move JS API: I'd expect the query to return the DPR of the current resource; if the resource changes it should return the new value. |
Currently the UA "remembers" which DPR variant it picks when making a request and then uses said value to scale the received asset before it's displayed - e.g. if a 2x selector is used, then the image is automatically scaled down by same factor before its displayed.
However, there are cases where what the client chooses, and what comes back (from server, cache, service worker, etc), are not the same:
To address above use cases, we need two things:
img.density = 2.0
, or some such.Content-DPR: 3.0
indicates that returned image response should be processed as a 3x asset.Content-DPR
header is spec'ed in CH: https://tools.ietf.org/html/draft-grigorik-http-client-hints-02#section-4.1 and we have a prototype implementation in Chrome.The text was updated successfully, but these errors were encountered: