Search code examples
svgsitecoresitecore7

Svg file into Media Library


I have a responsive design Sitecore 7 solution, I want to add svg files into Media Library to be processed exactly like jpg,jpeg pictures. When I upload svg files they are processed like media file not like image files.


Solution

  • As I know Sitecore CMS does not support SVG images out of the box. You are right, if you upload a SVG image, Sitecore will not process it as an image, but processes as a common media file. Thumbnails generation also does not work for a SVG image. Please try use the following media type definition for SVG type:

    <mediaType name="SVG image" extensions="svg">
      <mimeType>image/svg+xml</mimeType>
      <forceDownload>false</forceDownload>
      <sharedTemplate>system/media/unversioned/image</sharedTemplate>
      <versionedTemplate>system/media/versioned/image</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>
     </mediaType>
    

    Also please register mime types for svg files into configuration files.

    <configuration>
      <system.webServer>
        <staticContent>
         <remove fileExtension=".svg" />
         <mimeMap fileExtension=".svg" mimeType="image/svg+xml"/>
        </staticContent>
      </system.webServer>
    </configuration>