Sharepoint 2013 Display publishing image using content search webpart with custom display template

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/248000

  •  22-01-2021
  •  | 
  •  

質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top