4

We have recommendation from our seo team to use image format like jpeg 2000, jpeg XR, webp but when we try to upload Jpeg 2000 image with extension .jp2, sitecore not taking as image format instead it takes as file. Are we missing any configuration to support these image format?

1
  • 1
    Hi Kanmani, welcome to SSE! Unless there is a high demand, Sitecore is unlikely to add this by default. Richard did however provide with a good solution. Sep 26, 2018 at 19:52

1 Answer 1

2

welcome to SSE.

For Sitecore to recognize a .jp2 extension, you would need to set that up in the configuration of the media types.

Out of the box, the jpeg configuration is like this:

<mediaType name="JPEG image" extensions="jpg, jpeg, jpe, jfif">
    <mimeType>image/jpeg</mimeType>
    <forceDownload>false</forceDownload>
    <sharedTemplate>system/media/unversioned/jpeg</sharedTemplate>
    <versionedTemplate>system/media/versioned/jpeg</versionedTemplate>
    <mediaValidator type="Sitecore.Resources.Media.ImageValidator"/>
    <thumbnails>
        <generator type="Sitecore.Resources.Media.ImageThumbnailGenerator, Sitecore.Kernel">
            <extension>png</extension>
        </generator>
        <width>150</width>
        <height>150</height>
        <backgroundColor>#FFFFFF</backgroundColor>
    </thumbnails>
    <prototypes>
        <media type="Sitecore.Resources.Media.JpegMedia, Sitecore.Kernel"/>
    </prototypes>
</mediaType>

Notice that in the extentions attribute, jp2 is missing. You could either patch that to add jp2 or just add a new mediaType with the jp2 extension like this:

<mediaType name="JPEG image" extensions="jp2">
    <mimeType>image/jpeg</mimeType>
    <forceDownload>false</forceDownload>
    <sharedTemplate>system/media/unversioned/jpeg</sharedTemplate>
    <versionedTemplate>system/media/versioned/jpeg</versionedTemplate>
    <mediaValidator type="Sitecore.Resources.Media.ImageValidator"/>
    <thumbnails>
        <generator type="Sitecore.Resources.Media.ImageThumbnailGenerator, Sitecore.Kernel">
            <extension>png</extension>
        </generator>
        <width>150</width>
        <height>150</height>
        <backgroundColor>#FFFFFF</backgroundColor>
    </thumbnails>
    <prototypes>
        <media type="Sitecore.Resources.Media.JpegMedia, Sitecore.Kernel"/>
    </prototypes>
</mediaType>

Depending on your IIS settings you may also need to add a mime type in your web.config like this:

<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".jp2" />
            <mimeMap fileExtension=".jp2" mimeType="image/jp2"/>
        </staticContent>
    </system.webServer>
</configuration>

Its virtually the same solution for svg files from this post: Inserting SVG files/markup

2
  • Will Sitecore's image resizing handler support these new formats out of the box?
    – mp1990
    Dec 13, 2019 at 11:02
  • @mp1990 if you have further questions, please open these as a new question
    – Richard Seal
    Dec 13, 2019 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.