I am wanting to implement a solution where a server app returns an image that is just large enough to cover the entire device screen in any given orientation.
I have been learning a little about the HTTP Client Hints
method where the browser will send information along with a request for an image such as the screen size, pixel density etc. Then the server can parse that information and return the appropriately sized image.
This way I don't have to make any modifications to my existing image tags <img src="/myniceimage.jpg" />
and the extra information will be sent along with the request.
Unfortunately it appears support for this HTTP Client Hints feature is limited, see http://caniuse.com/#feat=client-hints-dpr-width-viewport
The only alternative to this feature that I can see (so that support isn't limited to Chrome) is moving the image to data-src
so the browser doesn't load it automatically and then have some javascript function load the image manually and also send along screen resolution and pixel density in the header for the request.
Is there some other way to get the screen size and pixel density sent to the server that doesn't require me to move my image links into data-src
and to have a javascript function manually load them. Or is there some other way to have the server use existing headers that all browsers send to somehow extrapolate that information or estimate it?
Thanks!