Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an Image in Web Browser use any file extension?

What if I rename an image with a custom file extension, will the choke up any browsers?

For example..

image.jpg

rename to:

image.xyz

Then in markup do..

<img src="image.xyz">

The image is still a JPEG format but simply uses a custom file extension. My tests all pass. Will this cause any potential issues?

like image 893
JavaScript_is_4_Real_men Avatar asked Feb 11 '23 17:02

JavaScript_is_4_Real_men


1 Answers

Yes, this is possible, but you'd need to set up a MIME type in your server. Browsers don't really care about the extension, but they do care about the MIME type that the server specifies that the image should be.

When a MIME type is set, it returns this in the Content-Type header of the response to the image request.

like image 94
trnelson Avatar answered Feb 16 '23 03:02

trnelson