'Set the correct filename extension in images downloaded from a site, to serve from my server, where the filename extension and MIME type do not match
I download programatically images from some sites to use them in my site. In some of those sites, the filename extension and the MIME type shown by browser dev tools are different, for example a filename named image.jpeg is shown to have WEBP MIME type. It seems that many image files with JPEG extension have WEBP or AVIF MIME type, which seems at least a bad practice IMO. My question is:
- Should I set the file extension of the downloaded images (to serve them from my server) with the correct MIME type or just set .jpeg extension ignoring the right MIME type?
- Could the image not be shown in some browsers if file extension and MIME type tell different formats?
I know that unlike Windows, Linux does not care about the extension of your files. It looks into the file contents and will figure it out by its own. In other words, Linux is extension agnostic. But I do not know how that works in a Linux or Windows browser.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
