0

I am working on a site in SP 2013 and want to display a series of items each with an image from a publishing image field in the item. I have created a custom display template but am having issues retrieving the image url from the field. The html is structured as follows:

<body>
<div id="Item_WebPage">

    if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){
        var id = ctx.ClientControl.get_nextUniqueId();
        var _title = $getItemValue(ctx, "Title");   
    var _updateTitle = $getItemValue(ctx, "Update Title");
        var _linkUrl = $getItemValue(ctx, "Link URL");
        var _updateContent = $getItemValue(ctx, "Update Content");
        var _updateImage = $getItemValue(ctx, "Update Image");

                                <div class="section-border"></div>
                                <div class="row">
                                    <div class="col-12 col-sm-4 tile image-tile image-tile-long">
                                        <img src="_#= _updateImage =#_" alt="featured image">
                                    </div>
                                    <div class="col-12 col-sm-8 tile long-tile">
                    <h1>_#= _updateTitle =#_</h1>
                                        <div>_#= STSHtmlDecode(_updateContent.value) =#_</div>
                                        <div class="white-button">
                                            _#= _linkUrl =#_
                                        </div>
                                    </div><!--long tile-->
                                </div><!--row-->

    } 

</div>

Currently the src for the image is returning as unknown. Is there some additional markup I need to include to parse the image link? Any assistance is appreciated.

  • I'm pretty sure the managed property is not called "Update Image" in the code. – YogaPanda Aug 29 '18 at 19:57
  • What is the value retrieved in _updateImage variable? – Gautam Sheth Aug 29 '18 at 20:03
2

The column can be renamed but the internal name would remained the same. I will check the internal column name before check anything below. If you are using the SharePoint Search Query Tool, you can see which managed property has the value you are looking for.

If not, you can either (1) make a REST call and manually find out the managed property or (2) go to the Schema under Site Setting, search for "Update Image" or "updateimage" in the crawled properties. You will find the name SharePoint uses, and search that name in the managed properties. You will probably find multiples. Add them into the template, and you will find out the real one.

  • 1
    I went ahead and checked the internal column name and it was different from what I had in the template. Updating it to the correct name worked. – bberndt Aug 30 '18 at 16:28

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.