One of my colleagues was asking about building a search which would show thumbnails for images, and whether that was possible. I decided to try a 5 minute prototype, so I took a copy of the results.aspx page in my Search Center, and started hacking…
I have a Picture library with some images in it (they’re pinched from Flickr, so sorry for the copyright thing to their respective owners – but they’re lovely looking test data). You might notice that the images in the pictures Library are already thumbnailed:
Firstly, I took a look at all the xml I was getting back from the search results. (You can add to that.)
Great! So I’m getting the thumbnail for the picture through in the search results, and I can also identify what pictures are by the ContentClass. Nice one!
The first thing I noticed on opening up the XSL for the normal results page was that there is a section about showing a thumbnail. Normal search results don’t show a thumbnail though – so what gives?
Well, there are a few conditions before it’ll show the thumbnails – the ContentClass of the result (which is okay), the presence of a thumbnail URL, and the variable $IsThisListScope being true. I’m not sure what the $IsThisListScope variable is for, but I decided to delete it from the condition. As the other parts are met the results should show thumbnails for items which have them (i.e. Pictures).
And if I perform a search for, say, balloons, then I get some results with thumbnails:
Now, it’s worth noting, this page will still show non-pictures results – just my results didn’t have any. The next step would be to create a scope to only include images.
3 thoughts on “Showing Thumbnails in Search”
[…] I’d looked at having a search that shows thumbnails of images in SharePoint. I modified the results page to do this – but the results themselves would still show […]
[…] Of course, image files being stored in a document library don’t have thumbnails, so that won’t work so well if you’re wanting to display thumbnails in something like the Search Results. […]
Nice one! Thanks for the great info!