Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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();
    }
}
share|improve this answer
    
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. –  Namwar Rizvi 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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