Create an Image only Search Scope in Sharepoint

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:

SSP Settings Page

If we View the Scopes, we get a list of the scopes and which Web Apps they’re available on:

Scopes List in SSP

Click on New Scope to create a new scope (obviously!) At this stage you only give it a name; rules are defined later:

New Scope Page

Hit OK and create the scope. The Scopes list view now prompts you to ‘Add Rules’ to the scope:

Scope List with new (empty) scope

Click on Add Rules to do so:

Add Scope Rule Page

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:

Update the scopes

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:

Settings page for Site Collection's top level site.

Click on Search Scopes:

Search Scopes in Site collection

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.

Edit Display Group Page

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:

Search results showing document and images

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:

Search Results with only Picture items

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.

Advertisement
Create an Image only Search Scope in Sharepoint

8 thoughts on “Create an Image only Search Scope in Sharepoint

  1. Fred says:

    Biggest problem with this solution is down to how Microsoft handles images on publishing pages. For whatever reason, the system generated image (or publishingimages) library is a DOCUMENT library, and the contents are not in the scope you set up. This is very frustrating, as fileextension is the only reliable way to ID images, but as you pointed out the actual image filename is not exposed.
    Fred

  2. gaurav says:

    “I configured my search page to display this drop down list (by editing the Search Box web part)” — how did you do this?

  3. – Go to the search results page.
    – Choose ‘Edit’ from the ‘Site Actions’ menu
    – On the Search Box Web Part use it’s menu to select ‘Modify Web Part’
    – In the Web part toolbox change the settings for the web part. I forget what it’s called, but there is one about whether a scopes drop down should be shown.

  4. Not sure, off the top of my head – normally images are just opened if you click on them in a browser.I don’t know if there is a browser setting that might control that behaviour – but that’d affect more than just your search page. Otherwise, there may be a way of doing it through JavaScript.

    Interesting question, if I get time I’ll maybe take a look at that.

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.