htmlmedia-type

HTML - Incorrect media type still correctly displays a base64 image


My webpage displays an image from a base64 string.

Even if I put a wrong media type, the image is still rendered correctly (I use Firefox). For example:

src="data:incorrect;base64, ...base 64 string..."

Is there any reason for that ?

Moreover, I cannot know in advance the format of the image to display (as they are uploaded by the user), so, should I use simply image as a media-type ?


Solution

  • Modern Browsers may display some common image types such as jpeg, png etc without proper mime type. but images in the form of SVG and all will not identify by the browser with out proper mime type. so it is better to use proper mime type even if it is working for you without proper mime.