Hi,
This has been a recurring problem in SharePoint: Although you add a publishingImage field to your layout and it gets indexed, the managed property mapped to this crawled property has no value.
This is related to two issues:
There are several solutions to resolved this scenario, but all they seem too complex (ex.: create a second field and update it with the url with an event receiver). Finally we get a simple solution without changing the product ;)
A sample of the webcontrol code:
using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; using Microsoft.SharePoint.Utilities; using Microsoft.SharePoint; using Microsoft.SharePoint.Publishing.Fields; namespace Microsoft.Services.WebControls { [DefaultProperty("Text"), ToolboxData("<{0}:IndexableImage runat=\"server\" />")] public class IndexableImage : WebControl { private static string getImageUrl(){ ImageFieldValue imgField = null; if (SPContext.Current.ListItem["metaImage"] != null) { imgField = (ImageFieldValue)SPContext.Current.ListItem["metaImage"]; if (imgField != null) { return imgField.ImageUrl; } } return string.Empty; } protected override void Render(HtmlTextWriter output) { output.Write("<meta"); output.WriteAttribute("name", "metaImage"); output.WriteAttribute("content", getImageUrl()); output.Write("/>"); output.WriteLine(); } } }
Namaste!
Could you please explain it more briefly....