...

View Full Version : Do you need a file extension for an image/photo to work on a website



britannic
01-01-2013, 09:52 PM
Hi:

Disclaimer: I am brand new to the forum and I do not write code. However, I do have a question regarding coding: Does a photo coded into a website need an extension, such a .jpg, gif. etc. in order to display and work properly on a website? Or can a photo's file name be titled SUNSET, not have an extension, and will display and work properly? Is it possible to accidentally drag a photo from a website to your desktop that does not have a file extension as part of the file name? While I am writing in the HTML and CSS forum my question applies to all types of website coding formats, styles, program, etc.

I would greatly appreciate any help on the subject.

tempz
01-01-2013, 10:45 PM
Yes.

It will need to be a "png, gif, jpg" but JPEG are used for large pixel pictures. "background etc"

VIPStephan
01-01-2013, 10:52 PM
Yes.

Iím not so sure about that. I think you can display an image in a browser even without a file extension, as long as the MIME type is correct.

But anyway, britannic: Why donít you just try it? Save an image without extension and load it in different browsers and you know it.

tempz
01-01-2013, 11:29 PM
Iím not so sure about that. I think you can display an image in a browser even without a file extension, as long as the MIME type is correct.

But anyway, britannic: Why donít you just try it? Save an image without extension and load it in different browsers and you know it.

Oh yes, I forgot that.



The file extension isn't used for anything, really. The browser is checking for the Content-type header, which should be something like image/jpeg or whatever type of image you're serving.

This is used pretty often in sites which dynamically serve images, often from a database. I've seen plenty of image URLs like image.aspx?id=37 which, while it technically has an "extension" doesn't really mean that it's an image. It's all in the HTTP header values.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum