We found an interesting problem with associating a custom icon with our file format to a custom Content Type. Let me try to explain.
Suppose we have a file format with a .tjc extension. (.tjc is just a made up file extension as an example)
If we upload a sample file, "sample.tjc", to a standard team site, the document is shown with a generic icon, which is defined by the default mapping element inside of 12HiveTemplateXMLDocicon.XML. This happens because we did not specify a file extension mapping for the .tjc file extension in the docicon.xml file
<DocIcons>
…
<Default>
<Mapping Value="icgen.gif"/>
</Default>
</DocIcons>
To associate the "TJC" file extension with a custom icon, we add the following line to the DOCICON.XML file, and perform an iisreset.
<Mapping Key="tjc" Value="ictjc.gif" EditText="My Custom Document Editor"
OpenControl="MyCustomEditor.OpenDocuments" />
Simple.
But what if we want to associate this icon with a custom type?
We start by creating a New Content Type:
Upload a .tjc file as the new document template:
Under the Settings ->Document Library Settings–> Advanced Settings for my document library, and toggle on the Content Types — Allow management of content types:
Then back on Document Library Settings page, I can add my custom Content Type, but clicking "Add from existing site content types:
And my custom Content type now appears in the list and should be visible on the new button.
But no icon appears:
The reason is the SharePoint code is looking for a larger version of the associated docicon.xml icon, and assumes that it similar names as the similar icon, but has a prepended "lg_" in front of it. In this example, it is looking for the file "lg_ictjc.gif".
Thus, we create a larger version of the icon,
and prepend the filename with "lg_" ,
add it to the 12HiveTemplateimages directory,
refresh your web browser,
And the custom icon will then appear.
Couple of other notes:
-
I f one use a custom Office document as your Content Type, it will just work without any modifications because both the small version and the large version of the icons already appear in the 12HiveTemplateImages directory.
- The size of the small icon is 16×16 pixels, 96×96 resolution and 8 bit color depth.
- The large icon should be 32 x32 pixels, 96×96 resolution and 8 bit color depth.
- If your small images are stored in a subfolder below images like this:
12HiveTemplateImagesMyCompanyictjc.gif
You will need to create an equivalent subfolder with a prepended "lg_" rather than the image filename itself:
12HiveTemplateImageslg_MyCompanyictjc.gif
More about the docicon.xml file, can be found here:
http://msdn2.microsoft.com/en-us/library/ms463701.aspx
Hope this helps someone.
Tom
Tags: wssv3