Certain types of Icons are not being displayed in search results with Sharepoint 2013

It looks like Sharepoint 2013 Search results are not showing little icons that display the file type next to each result, specifically non-Office/non-PDF type docs. File types like ZIP, EML, MHT and some others have icons displayed next to them just fine when loaded into a Document Library, but not as part of a search result set.

After checking all the basics, such as making sure docicons.xml file had proper extensions and icons referenced, this looks like a potential product issue.  Pretty easily reproducible and I’ve then tried to use IE Developer Tools to see whether an image file is actually being requested when searching for Word Document versus a Zip File.

Scenario 1:

Searching for a Word document, icdocx.png image is being pulled as expected from the Images directory:

Word_Icon_Debugging

 

Scenario 2:

Searching for a Zip file, we would expect to try grabbing ‘iczip.gif’ file as per this Mapping, but it’s not actually happening:

<Mapping Key=”zip” Value=”iczip.gif” OpenControl=””/>

Zip_Icon_Debugging

 

 

What I think may be happening is this.  There is a Default_Item Display Template which calls Item_CommonItem_Body template for rendering of the body.  There is a specific call that just doesn’t seem to be working well (highlighted):

<!–#_

 

if (!$isEmptyString(ctx.CurrentItem.csr_Icon)) {

_#–>

<div class=”ms-srch-item-icon”>

<img id=”_#= $htmlEncode(id + Srch.U.Ids.icon) =#_” onload=”this.style.display=’inline'” src=”_#= $urlHtmlEncode(ctx.CurrentItem.csr_Icon) =#_” />

</div>

<!–#_

 

As a quick test, I simply took out the “if” clause and used FileExtension property to workaround.  Not sure if it’s the most graceful solution, but at least now every file that has a FileExtension property populated will get an Icon associated with it.  This should cover majority of these use-cases such as ZIP, EML, etc.  Documents that do not have a defined FileExtension (such as Web pages) will still have missing icons.

 

<div class=”ms-srch-item-icon”>

<img id=”_#= $htmlEncode(id + Srch.U.Ids.icon) =#_” onload=”this.style.display=’inline'” src=’_#= “/_layouts/15/images/ic” + $htmlEncode(ctx.CurrentItem.FileExtension) + “.gif” =#_’ />

</div>

 

About Igor Veytskin

I have been working with Enterprise Search since 2005, ever since joining a company called FAST Search & Transfer. I'm currently working as a Premier Field Engineer with Microsoft, helping customers with large ESP, FS14 and Sharepoint 2013 implementations.
This entry was posted in SP2013, Uncategorized and tagged , , , , . Bookmark the permalink.

2 Responses to Certain types of Icons are not being displayed in search results with Sharepoint 2013

  1. There’s a function used by the default templates to get the icon, and not all ic_ files are gif, some are png. That said, we use the same solution as you are with custom icons where we have a filename convention.

    You might want to add onerror=”this.src=somedefaultimage” to your img tag to handle formats where there is no icon.

  2. Markus says:

    Hi,
    I had a similar issue in an enviorment. Some Excle-Files had a icon, and some were without an icon.
    The problem was that the managed property “FileType” was not filled. To resolve this I modified the mapping of the managed property “FileType”. Initially it was only mapped to the crawled property “FileType”, I added “FileExtension” as a fallback value to the managed property “FileType”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s