Developer Corner - Image file has incorrect type

05 Oct 2020 | Developer Corner

Helen Grimbly
  • Tweet this item
  • share this item on Linkedin

This week, Helen explains what to do when an 'Image file has incorrect type' error has been raised.

file/image/badtype: Image file has incorrect type

This is a Sitemorse Function error that is raised when a file used as an image in an HTML page is being served with a MIME type that indicates it is not an image, or that does not match the actual image file format.

Example 1: 'File used as image but is of type 'text/html''

An example error message could be 'File used as image but is of type 'text/html''. Here a file has been used as an image in an HTML page, but is being served with a MIME type 'text/html', that indicates it is not an image. This most commonly may indicate a server misconfiguration.

Example 2: 'GIF image expected but found PNG'

A second example is if an image file is being served with a file format PNG, but its MIME type is image/gif, then an 'Image file has incorrect type' would be raised. This is most commonly caused by an image file being renamed (e.g. from example.png to example.gif). 
Note the first step to resolve this issue, is to investigate the actual file format of the image in question. For example, you could open the image in an image editor and see what file format it indicates that it is. The image should then either be renamed to the correct file extension, or re-saved from the image editor in the desired format.

This is a secondary Function error and will affect the score.