0

I want to display the Picture of Publishing Image field in my search results page. CQWP can easily display that image but Search Results web part gives error that "Property doesn't exist or is used in a manner inconsistent with schema settings."

After Googling for a while, I realized that Publishing Image is stored as HTML and SSP crawler just ignores HTML stuff in fields.

Has any body ever displayed the Publishing Images in Search Result?

1

One way to do this is to create a separate field use an Event Handler to extract the image URL and store it separately against each page. The SharePoint search crawler can then be set up to index this additional field. The example below shows how you could do this with an additional text field called 'SearchImageUrl' in an SPItemEventReceiver that is attached to the Pages library:

public override void ItemUpdated(SPItemEventProperties properties)
{
    ImageFieldValue image = properties.ListItem["Rollup Image URL"] as ImageFieldValue;
    if (image != null && !string.IsNullOrEmpty(image.ImageUrl))
    {
        properties.ListItem["SearchImageUrl"] = image.ImageUrl;

    }
    try
    {
        this.DisableEventFiring();
        properties.ListItem.SystemUpdate(false);
    }
    finally
    {
        this.EnableEventFiring();
    }
}
3
  • Ari, could you also set this in the AfterProperties of the ItemUpdating event?
    – Paul Lucas
    Aug 27 '10 at 2:07
  • Thanks, but this will not be feasible from maintenance point of view. I was looking for something without adding events or separate fields to copy the url. Thanks, anyway. Aug 27 '10 at 9:12
  • Paul - I haven't tried that scenario as when I have done this before I wanted the event to be asynchronous but that sounds plausible
    – Ari Bakker
    Aug 27 '10 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.