Previously 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 non-Picture items (e.g. documents, pages, etc.). In this post, I’ll configure up a new Search Scope for images only.
Search Scopes are found through the Shared Service Provider (SSP) Search settings page:
If we View the Scopes, we get a list of the scopes and which Web Apps they’re available on:
Click on New Scope to create a new scope (obviously!) At this stage you only give it a name; rules are defined later:
Hit OK and create the scope. The Scopes list view now prompts you to ‘Add Rules’ to the scope:
Click on Add Rules to do so:
Rules can be based on a number of things – Content Source, Web Address, or Property. Properties are just Managed Properties that are configured to allow themselves to be used in scopes. You can add to those Managed Properties and make more available in this list.
For our scope, I’m using the ContentClass property. I know from my previous article the value that this is for Picture items, and I’m going to make this rule Required – I want all items in this scope to have the content class of STS_ListItem_PictureLibrary (that just trips off the tongue).
Anyway, once those fields have been filled in, press OK. Go back to the Search Settings page and go to the Scope section:
The scopes periodically update themselves; this section will tell you when the next update is. If you’re impatient, you can kick off an update immediately.
So, once the scope is created and updated, we want to use it. First, we have to configure it in our Site Collection. This does mean that different site collections can share (or not) different scopes. Go to the Site Collection Settings:
Click on Search Scopes:
This shows us the search scopes available in the site collection and the ‘Display Groups’ those scopes are in. ‘Display Groups’ controls where the scopes are available. For example, the above screenshot shows the scopes available for the small search box and the advanced search.
We’ll add our scope to the small search box. Click on Search Dropdown.
Now we can edit the display group. Check the ‘Display’ checkbox next to our Images scope. Hit OK.
Next we need to go to a page which uses the small search box and shows the scope drop down list. Your system might not always show that list. I configured my search page to display this drop down list (by editing the Search Box web part), and ran a search for ‘snake’ using the default ‘All sites’ scope:
This returned me document and images about snakes. I then used the drop down box to select my ‘Image’ scope, and ran the search again:
Hurray! Search results about snakes that only include Picture items in Picture Libraries. Obviously, you may want some sort of more complex Scope Rules to accept pictures from other sources.
Be careful about using the FileExtension managed property though (as suggested here) as the FileExtension property for images comes through in the results XML as
ASPX?ID=x . I don’t get why, but I don’t seem to be able to get a url such as
http://server/documents/myimage.jpg – instead they all come through as
http://server/documents/Forms/DispForm.aspx?ID=x . I’ll investigate that sometime; this doesn’t seem to be a factor of the XSL though.
Anyway, using Picture Libraries is good if you can get away with it.