2

I created a custom item display template. This custom item display template is using my custom hover display template. In my hover display template I get a managed property CustomImage. When I add this managed property in a div I can see the picture in the hover display template. I would like to set a fixed picture width and height in my hover display template. How can I do this? Code below is not working:

<body>
    <div id="Custom_Item_HoverPanel">
<!--#_
        var i = 0;
        var id = ctx.CurrentItem.csr_id;
        ctx.CurrentItem.csr_ShowViewLibrary = !Srch.U.isWebPage(ctx.CurrentItem.FileExtension);
        if(ctx.CurrentItem.IsContainer)
        {
            ctx.CurrentItem.csr_FileType = Srch.Res.ct_Folder
        }

        ctx.currentItem_ShowChangedBySnippet = true;

        var publishingImage = $getItemValue(ctx, 'CustomImage');
        var pictureMarkup = Srch.ContentBySearch.getPictureMarkup(publishingImage, 100, 100, ctx.CurrentItem, '', '', '');
_#-->
        <div class="ms-srch-hover-innerContainer ms-srch-hover-standardSize" id="_#= $htmlEncode(id + HP.ids.inner) =#_">
            <div class="ms-srch-hover-arrowBorder" id="_#= $htmlEncode(id + HP.ids.arrowBorder) =#_"></div>
            <div class="ms-srch-hover-arrow" id="_#= $htmlEncode(id + HP.ids.arrow) =#_"></div>
            <div class="ms-srch-hover-content" id="_#= $htmlEncode(id + HP.ids.content) =#_" data-displaytemplate="DefaultHoverPanel">
                <div id="_#= $htmlEncode(id + HP.ids.header) =#_" class="ms-srch-hover-header">
                    _#= ctx.RenderHeader(ctx) =#_
                </div>
                <div id="_#= $htmlEncode(id + HP.ids.body) =#_" class="ms-srch-hover-body">
                    _#= ctx.RenderBody(ctx) =#_
                </div>  
                    <div style="padding:20px;">_#= pictureMarkup =#_</div>                              
                <div id="_#= $htmlEncode(id + HP.ids.actions) =#_" class="ms-srch-hover-actions">
                    _#= ctx.RenderFooter(ctx) =#_
                </div>
            </div> 
        </div>
    </div>
</body>

I think the technology Srch.ContentBySearch.getPictureMarkup is working only on the search result webpart. I use the content by search webpart.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.