6 ms·
> 5% of people can't view them, yet 25% of top websites use them? That's not how it works. The server declares what versions of media it has, and the client r
by 0points 1y ago
> 5% of people can't view them, yet 25% of top websites use them?
That's not how it works.
The server declares what versions of media it has, and
the client requests a supported media format. The same trick have been used for audio and video for ages too.
Example:
<picture>
<source srcset="a.webp" type="image/webp">
<img src="fallback.jpg">
</picture>
- vbezhenar 1y agoThis problem was solved by HTTP since forever. Client sends `Accept` header with supported formats and server selects the necessary content with corresponding `Content-Type` header. You don't need any HTML tags for it.
- allendoerfer 1y agoWhat about file extensions?
- jdiff 1y agoSometimes respected, largely ignored. URLs very often don't map directly to files served.
- allendoerfer 1y agoImages almost always do.
- jdiff 1y agoI wish, would make my job a good bit easier. Sometimes they don't even respect format query parameters and just use whatever's in your Accept headers. Will say though that it's not universal, it depends heavily on the corner of the internet you're on.
- georgyo 1y agoFile extensions are just a hint about what the file might be and have nothing to do with what the file actually is. If the server sets the MIME type, the browser will use that as the hint. But even beyond that, most file formats have a bit of a header at the start of the file that declares the actual format of the file. Browsers already can understand that and use the correct render for a file without an extension.
- allendoerfer 1y agoWhat if the user wants to use the file outside the browser, where they do not have access to the HTTP headers?
- georgyo 1y agoThe same is true, if you rename a .png to .jpg and opening it with an image viewer, it will render.
- NorwegianDude 1y agoNo, cause thats just one of the features. Images are often at different resolutions too, that way, depending on the pixel density of the device, and the physical size, the browser can select the photo that has high enough resolution, but not one that is needlessly large, while also selecting the preferred image format.