Hi,
I am looking for some assistance. I would like to use the Page Image field in a Item Display Template. I have created the managed property and called it PublishingPageImage. I have added it to <mso:ManagedPropertyMapping section of my Item_DisplayTemplate. It is then referenced in my html using a javascript variable var pubImage = $getItemValue(ctx, “PublishingPageImage”;) and finally referenced it in my DIV using _#= pubImage =#_
The problem is when everything renders on the page i get the following, instead of the image being rendered
Text – <img alt=”” src=”/PublishingImages/2-150-insider-story.jpg” style=”BORDER:0px solid;” />
Can anyone suggest how I might go about using this field to render an image on a display template?
Please see attachments.
Thank you.
-Matt
I was wondering why i could not track down that information. I recognized the code from other templates as you said. Thanks again.
I have had problems finding documentation on the JS api avialable to us in Display Templates. I got almost all of my knowledge by digging into the OOTB Display templates. You will find my pseudocode came from the item templates such as the large image and picture with 3 lines.
Hi Eric,
A variation of your suggestion rendered the images. Thank you!
-Matt
PS. I cannot find API documentation for “Srch.ContentBySearch.getPictureMarkup” Do you know where it comes from?
Have you tried something like:
var encodedId = $htmlEncode(ctx.ClientControl.get_nextUniqueId() + “_customId_”);
var pictureURL = $getItemValue(ctx, “PublishingPageImage”);
var pictureId = encodedId + “picture”;
var pictureMarkup = Srch.ContentBySearch.getPictureMarkup(pictureURL, 468, 220, ctx.CurrentItem, “cbs-customClass”, “Your alt text”, pictureId);
…
<a class=”” href=”_#= linkURL =#_” title=”_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_” id=”_#= pictureLinkId =#_”>
_#= pictureMarkup =#_
</a>
_customId_ coming from where?