3 ms·
Ask HN: Image Negotiation
Hi all,
Is there any way for a browser to negotiate image size with the server?
A lot more sites are now being designed using responsive techniques. This may lead to images of various sizes being need. One way of doing this is to embed a few IMG tags and then set display:none on all but the img you want. However, this means the client will download all of the images, most of which won't be displayed.
The size of the image can be calculated by the browsers, provided style="width: x; height: y" is set (probably within a media query somewhere) and this could be sent up using a header. I think the most appropriate would be the Accept-Features header, but it doesn't seem like it is supported.
Is this possible now? Will it become possible? Thoughts please.
- mooism2 15y agoCan you do <span id="whatever"> </span> and then set width, height and background-image in the css using media queries? I don't know whether clients will download all the images or just the one needed.