February 17, 2011

Adding custom icons for the media library

If you need to have some custom icons in the media library you have several options:
  • Install the corresponding program on the computer and associate the file with this program (ie: acrobat reader for .pdf files). This option is maybe not an option for the production server.
  • Associate the file extension in the operating system. Open "Control Panel -> Folder Options-> File Types -> New -> Add file Extension" then register the icon for this extension (Advanced -> Change Icon)
  • Associate the Icon with the file extension in your web.config. Add thumbnails generator for the known file type. For example for PDF file type:
    <mediaType name="PDF file" extensions="pdf">
      <mimeType>application/pdf</mimeType>
      <forceDownload>false</forceDownload>
      <sharedTemplate>system/media/unversioned/pdf</sharedTemplate>
      <versionedTemplate>system/media/versioned/pdf</versionedTemplate>
      <thumbnails>
        <generator type="Sitecore.Resources.Media.MediaThumbnailGenerator, Sitecore.Kernel">
          <extension>png</extension>
        </generator>
        <staticFile>Path where the icon is located. For example /sitecore/shell/Themes/standard/images/pdf_icon.png</staticFile>
      </thumbnails>
    </mediaType>
    

After these modification, clear the cached files:
  1. Open the folder "/Temp" under the Sitecore root.
  2. Delete all files with the name "fileicon.....".
  3. Clear media cache "/App_Data/MediaCache" under the Sitecore root.

1 comment: