ASPX templates
Version 6.x > ASPX templates > Broken preview images for CMS.File documents in smart search results View modes: 
User avatar
Certified Developer 9
Certified Developer 9
jkh80 - 5/31/2012 2:01:42 PM
   
Broken preview images for CMS.File documents in smart search results
I have a smart search for my site that is rendering results using the SmartSearchResultsWithImages transformation. The preview images show up fine in the results, except for when a CMS.File document is in the results that has an attachment of .PDF, .doc, .xls, etc.

In these cases, the image just shows up as broken. Has anyone run into this and managed to find a way around it?

My only thought at the moment is to write a method that would replace the GetSearchImageUrl() method currently in the transformation that would show the appropriate icon if the document is a CMS.File, or just use the default behaviour otherwise.

Is there any other way?

User avatar
Member
Member
kentico_edwardh - 6/1/2012 2:25:22 PM
   
RE:Broken preview images for CMS.File documents in smart search results
First, you can find all the icons used for a specific file type in the following folder: ~\App_Themes\Default\Images\FileIcons\ and the icons used for document types can be found here: ~\App_Themes\Default\Images\DocumentTypeIcons\

Inside the search results transformation you could use <%# GetSearchValue("classname")%>. This example code should return the code name of the given document type, like CMS.Blog for blog document, CMS.MenuItem for page (menu item) document, and so on. Then inside the src property of image control you can link to the file icon for the given document type

<img src="<%# "/some/url/" +GetSearchValue("classname").ToString() + ".gif" %>" /

Best Regards,
Edward Hillard