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>

 

Comments (0)

Skip to main content