In this post I will show you how to use image renditions from a custom Display template. If you are new with Display temlates, I suggest you to read the following article from Chris O’Brien, and if you are starting with image renditions, this article from Waldek Mastykarz is perfect.
In this sample, I’m using a Search results webpart (not a CBSWP, that is not available on SharePoint Online), with a custom display template. The display template is configured with this Managed properties:
1 |
<span style="color: #606060" id="lnum1"> 1:</span> ctx[<span style="color: #006080">'DisplayTemplateData'</span>][<span style="color: #006080">'ManagedPropertyMapping'</span>] = { <span style="color: #006080">'Title'</span>: [<span style="color: #006080">'Title'</span>], |
1 |
<span style="color: #606060" id="lnum2"> 2:</span> <span style="color: #006080">'Path'</span>: [<span style="color: #006080">'Path'</span>], <span style="color: #006080">'Description'</span>: [<span style="color: #006080">'Description'</span>], |
1 |
<span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #006080">'EditorOWSUSER'</span>: [<span style="color: #006080">'EditorOWSUSER'</span>], |
1 |
<span style="color: #606060" id="lnum4"> 4:</span> <span style="color: #006080">'LastModifiedTime'</span>: [<span style="color: #006080">'LastModifiedTime'</span>], |
1 |
<span style="color: #606060" id="lnum5"> 5:</span> <span style="color: #006080">'CollapsingStatus'</span>: [<span style="color: #006080">'CollapsingStatus'</span>], |
1 |
<span style="color: #606060" id="lnum6"> 6:</span> <span style="color: #006080">'DocId'</span>: [<span style="color: #006080">'DocId'</span>], <span style="color: #006080">'HitHighlightedSummary'</span>: [<span style="color: #006080">'HitHighlightedSummary'</span>], |
1 |
<span style="color: #606060" id="lnum7"> 7:</span> <span style="color: #006080">'HitHighlightedProperties'</span>: [<span style="color: #006080">'HitHighlightedProperties'</span>], |
1 |
<span style="color: #606060" id="lnum8"> 8:</span> <span style="color: #006080">'FileExtension'</span>: [<span style="color: #006080">'FileExtension'</span>], |
1 |
<span style="color: #606060" id="lnum9"> 9:</span> <span style="color: #006080">'ViewsLifeTime'</span>: [<span style="color: #006080">'ViewsLifeTime'</span>], <span style="color: #006080">'ParentLink'</span>: [<span style="color: #006080">'ParentLink'</span>], |
1 |
<span style="color: #606060" id="lnum10"> 10:</span> <span style="color: #006080">'DisplayAuthor'</span>: [<span style="color: #006080">'DisplayAuthor'</span>], |
1 |
<span style="color: #606060" id="lnum11"> 11:</span> <span style="color: #006080">'Picture URL'</span>: [<span style="color: #006080">'PublishingImage'</span>, <span style="color: #006080">'PublishingRollupImage'</span>, <span style="color: #006080">'Rollup Image'</span>], |
1 |
<span style="color: #606060" id="lnum12"> 12:</span> <span style="color: #006080">'ArticleByLineOWSTEXT'</span>: [<span style="color: #006080">'ArticleByLineOWSTEXT'</span>] }; |
If we want to get the value of a Managed property on the display template, we can do something like that (of course, the property has to be set on the display template first):
1 |
<span style="color: #606060" id="lnum1"> 1:</span> ctx.CurrentItem.Path |
or even something like that:
1 |
<span style="color: #606060" id="lnum1"> 1:</span> ctx.CurrentItem[<span style="color: #006080">"Path"</span>] |
but it’s a better option to use the following function:
1 |
<span style="color: #606060" id="lnum1"> 1:</span> $getItemValue(ctx, <span style="color: #006080">"Picture URL"</span>) |
with this function, we are getting a Srch.valueInfo object, that contains some interesting properties, as we can see in the next image:
- value: the value of the property
- isEmpty and isNull: quite useful to check if the property has a value
- propertylookupName: this is the name of the slot that we are using to store the Managed property.
- propertyMappings: and array with all the managed properties that we are including in the slot. As we can on the ManagedPropertyMapping array defined on the display template, the slot “Picture URL”, is mapped with 3 managed properties.
- managedPropertyName: this is the managed property source of the value. In this case, we are mapping the slot with 3 properties, and the value is coming from the “PublishingImage” property.
with this object, we can use a SharePoint JS function to get the image URL with the rendition that we want to apply:
1 |
<span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff">var</span> image = $getItemValue(ctx, <span style="color: #006080">"Picture URL"</span>); |
1 |
<span style="color: #606060" id="lnum2"> 2:</span> <span style="color: #0000ff">var</span> imageUrlWithRendition = Srch.U.getImageSourceWithRendition(image, 190, 120) |
This code will return the image URL with the width and height parameters:
Unfortunately, the SharePoint JSOM is almost undocumented on the MSDN, so, to find out this function and much more, I suggest you to take a look to all the OOB display templates, and use the Developer tools in Chrome to debug the client code and test the results of some functions.
With the value returned for the function, we can compose other IMG tag, and the result will be an image using the rendition that we want: 190×120.
Also, when you are working with display template, you will find useful to use the Diagnostic display template, which shows you all the managed properties used in the template, with its value and other information. This template is only available for the Content By Search webpart, but with a couple of changes, you can use the template in the Search Resutls webpart if you are working with SharePoint Online. This is the diagnostic template code for the Search Results WP
1 |
<span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff">function</span> ULScqk(){<span style="color: #0000ff">var</span> o=<span style="color: #0000ff">new</span> Object;o.ULSTeamName=<span style="color: #006080">"Search Server"</span>;o.ULSFileName=<span style="color: #006080">"Item_Diagnostic.js"</span>;<span style="color: #0000ff">return</span> o;} |
1 |
<span style="color: #606060" id="lnum2"> 2:</span> <span style="color: #0000ff">function</span> DisplayTemplate_6be7c3604a7e4519a210e962b4ed867c(ctx) {ULScqk:; |
1 |
<span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #0000ff">var</span> ms_outHtml=[]; |
1 |
<span style="color: #606060" id="lnum4"> 4:</span> <span style="color: #0000ff">var</span> cachePreviousTemplateData = ctx[<span style="color: #006080">'DisplayTemplateData'</span>]; |
1 |
<span style="color: #606060" id="lnum5"> 5:</span> ctx[<span style="color: #006080">'DisplayTemplateData'</span>] = <span style="color: #0000ff">new</span> Object(); |
1 |
<span style="color: #606060" id="lnum6"> 6:</span> DisplayTemplate_6be7c3604a7e4519a210e962b4ed867c.DisplayTemplateData = ctx[<span style="color: #006080">'DisplayTemplateData'</span>]; |
1 |
<span style="color: #606060" id="lnum7"> 7:</span> |
1 |
<span style="color: #606060" id="lnum8"> 8:</span> ctx[<span style="color: #006080">'DisplayTemplateData'</span>][<span style="color: #006080">'TemplateUrl'</span>]=<span style="color: #006080">'~sitecollectionu002f_catalogsu002fmasterpageu002fDisplay Templatesu002fSearchu002fItem_Diagnostic.js'</span>; |
1 |
<span style="color: #606060" id="lnum9"> 9:</span> ctx[<span style="color: #006080">'DisplayTemplateData'</span>][<span style="color: #006080">'TemplateType'</span>]=<span style="color: #006080">'Item'</span>; |
1 |
<span style="color: #606060" id="lnum10"> 10:</span> ctx[<span style="color: #006080">'DisplayTemplateData'</span>][<span style="color: #006080">'TargetControlType'</span>]=[<span style="color: #006080">'Content Web Parts'</span>]; |
1 |
<span style="color: #606060" id="lnum11"> 11:</span> <span style="color: #0000ff">this</span>.DisplayTemplateData = ctx[<span style="color: #006080">'DisplayTemplateData'</span>]; |
1 |
<span style="color: #606060" id="lnum12"> 12:</span> |
1 |
<span style="color: #606060" id="lnum13"> 13:</span> ctx[<span style="color: #006080">'DisplayTemplateData'</span>][<span style="color: #006080">'ManagedPropertyMapping'</span>]={<span style="color: #006080">'Picture URL'</span>:[<span style="color: #006080">'PublishingImage'</span>, <span style="color: #006080">'PictureURL'</span>, <span style="color: #006080">'PictureThumbnailURL'</span>], <span style="color: #006080">'Path'</span>:<span style="color: #0000ff">null</span>, <span style="color: #006080">'SecondaryFileExtension'</span>:<span style="color: #0000ff">null</span>, <span style="color: #006080">'ContentTypeId'</span>:<span style="color: #0000ff">null</span>, <span style="color: #006080">'Line 1'</span>:[<span style="color: #006080">'Title'</span>], <span style="color: #006080">'Line 2'</span>:[<span style="color: #006080">'Description'</span>], <span style="color: #006080">'Line 3'</span>:[<span style="color: #006080">'ArticleByLineOWSTEXT'</span>], <span style="color: #006080">'Line 4'</span>:[], <span style="color: #006080">'Line 5'</span>:[], <span style="color: #006080">'Line 6'</span>:[], <span style="color: #006080">'Line 7'</span>:[], <span style="color: #006080">'Line 8'</span>:[], <span style="color: #006080">'Line 9'</span>:[], <span style="color: #006080">'Line 10'</span>:[]}; |
1 |
<span style="color: #606060" id="lnum14"> 14:</span> <span style="color: #0000ff">var</span> cachePreviousItemValuesFunction = ctx[<span style="color: #006080">'ItemValues'</span>]; |
1 |
<span style="color: #606060" id="lnum15"> 15:</span> ctx[<span style="color: #006080">'ItemValues'</span>] = <span style="color: #0000ff">function</span>(slotOrPropName) {ULScqk:; |
1 |
<span style="color: #606060" id="lnum16"> 16:</span> <span style="color: #0000ff">return</span> Srch.ValueInfo.getCachedCtxItemValue(ctx, slotOrPropName) |
1 |
<span style="color: #606060" id="lnum17"> 17:</span> }; |
1 |
<span style="color: #606060" id="lnum18"> 18:</span> |
1 |
<span style="color: #606060" id="lnum19"> 19:</span> ms_outHtml.push(<span style="color: #006080">''</span>,<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum20"> 20:</span> ); |
1 |
<span style="color: #606060" id="lnum21"> 21:</span> <span style="color: #0000ff">var</span> encodedId = $htmlEncode(ctx.ClientControl.get_nextUniqueId() + <span style="color: #006080">"_Diagnostic_"</span>); |
1 |
<span style="color: #606060" id="lnum22"> 22:</span> |
1 |
<span style="color: #606060" id="lnum23"> 23:</span> <span style="color: #0000ff">var</span> linkURL = $getItemValue(ctx, <span style="color: #006080">"Path"</span>); |
1 |
<span style="color: #606060" id="lnum24"> 24:</span> linkURL.overrideValueRenderer($urlHtmlEncode); |
1 |
<span style="color: #606060" id="lnum25"> 25:</span> |
1 |
<span style="color: #606060" id="lnum26"> 26:</span> <span style="color: #0000ff">var</span> line1 = $getItemValue(ctx, <span style="color: #006080">"Line 1"</span>); |
1 |
<span style="color: #606060" id="lnum27"> 27:</span> <span style="color: #0000ff">var</span> pictureURL = $getItemValue(ctx, <span style="color: #006080">"Picture URL"</span>); |
1 |
<span style="color: #606060" id="lnum28"> 28:</span> pictureURL.overrideValueRenderer($urlHtmlEncode); |
1 |
<span style="color: #606060" id="lnum29"> 29:</span> <span style="color: #0000ff">var</span> pictureId = encodedId + <span style="color: #006080">"picture"</span>; |
1 |
<span style="color: #606060" id="lnum30"> 30:</span> <span style="color: #0000ff">var</span> pictureMarkup = pictureURL <span style="color: #008000">//Srch.ContentBySearch.getPictureMarkup(pictureURL, 100, 100, ctx.CurrentItem, "cbs-picture3LinesImg", line1, pictureId);</span> |
1 |
<span style="color: #606060" id="lnum31"> 31:</span> |
1 |
<span style="color: #606060" id="lnum32"> 32:</span> window.cbsDiagnostic_RenderPropertyMappings = <span style="color: #0000ff">function</span>(valueInfoObj) |
1 |
<span style="color: #606060" id="lnum33"> 33:</span> {ULScqk:; |
1 |
<span style="color: #606060" id="lnum34"> 34:</span> <span style="color: #0000ff">var</span> combinedManagedPropertiesMapping = <span style="color: #006080">""</span>; |
1 |
<span style="color: #606060" id="lnum35"> 35:</span> <span style="color: #0000ff">if</span>(!$isNull(valueInfoObj) && !$isNull(valueInfoObj.propertyMappings) && !$isNull(valueInfoObj.propertyMappings.length)) |
1 |
<span style="color: #606060" id="lnum36"> 36:</span> { |
1 |
<span style="color: #606060" id="lnum37"> 37:</span> <span style="color: #0000ff">for</span> (<span style="color: #0000ff">var</span> i = 0; i < valueInfoObj.propertyMappings.length; i++) |
1 |
<span style="color: #606060" id="lnum38"> 38:</span> { |
1 |
<span style="color: #606060" id="lnum39"> 39:</span> <span style="color: #0000ff">var</span> managedPropertyName = valueInfoObj.propertyMappings[i]; |
1 |
<span style="color: #606060" id="lnum40"> 40:</span> combinedManagedPropertiesMapping += i == 0 ? managedPropertyName : String.format(Srch.Res.edisc_MultiValueFormat, managedPropertyName); |
1 |
<span style="color: #606060" id="lnum41"> 41:</span> } |
1 |
<span style="color: #606060" id="lnum42"> 42:</span> } |
1 |
<span style="color: #606060" id="lnum43"> 43:</span> <span style="color: #0000ff">return</span> $htmlEncode(combinedManagedPropertiesMapping); |
1 |
<span style="color: #606060" id="lnum44"> 44:</span> } |
1 |
<span style="color: #606060" id="lnum45"> 45:</span> |
1 |
<span style="color: #606060" id="lnum46"> 46:</span> <span style="color: #0000ff">var</span> itemContainerTitle = <span style="color: #0000ff">null</span>; |
1 |
<span style="color: #606060" id="lnum47"> 47:</span> <span style="color: #0000ff">var</span> canBuildItemContainerTitle = !$isNull(ctx.CurrentItemIdx) && !$isNull(ctx.CurrentGroup) && |
1 |
<span style="color: #606060" id="lnum48"> 48:</span> !$isNull(ctx.CurrentGroup.ResultRows) && !$isNull(ctx.CurrentGroup.ResultRows.length) && |
1 |
<span style="color: #606060" id="lnum49"> 49:</span> !isNaN(ctx.CurrentGroup.ResultRows.length) && !isNaN(ctx.CurrentItemIdx); |
1 |
<span style="color: #606060" id="lnum50"> 50:</span> <span style="color: #0000ff">if</span>(canBuildItemContainerTitle) |
1 |
<span style="color: #606060" id="lnum51"> 51:</span> { |
1 |
<span style="color: #606060" id="lnum52"> 52:</span> itemContainerTitle = String.format($resource(<span style="color: #006080">"item_Diagnostic_ItemTitleFormat"</span>), ctx.CurrentItemIdx + 1, ctx.CurrentGroup.ResultRows.length); |
1 |
<span style="color: #606060" id="lnum53"> 53:</span> } |
1 |
<span style="color: #606060" id="lnum54"> 54:</span> |
1 |
<span style="color: #606060" id="lnum55"> 55:</span> <span style="color: #0000ff">var</span> containerId = encodedId + <span style="color: #006080">"container"</span>; |
1 |
<span style="color: #606060" id="lnum56"> 56:</span> <span style="color: #0000ff">var</span> pictureSlotContainerId = encodedId + <span style="color: #006080">"pictureSlotContainer"</span>; |
1 |
<span style="color: #606060" id="lnum57"> 57:</span> <span style="color: #0000ff">var</span> pictureContainerId = encodedId + <span style="color: #006080">"pictureContainer"</span>; |
1 |
<span style="color: #606060" id="lnum58"> 58:</span> <span style="color: #0000ff">var</span> pictureLinkId = encodedId + <span style="color: #006080">"pictureLink"</span>; |
1 |
<span style="color: #606060" id="lnum59"> 59:</span> <span style="color: #0000ff">var</span> pathContainerId = encodedId + <span style="color: #006080">"pathContainer"</span>; |
1 |
<span style="color: #606060" id="lnum60"> 60:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum61"> 61:</span> ,<span style="color: #006080">' <ul class="cbs-diagnostic-Container" id="'</span>, containerId ,<span style="color: #006080">'" data-displaytemplate="ItemDiagnostic">'</span> |
1 |
<span style="color: #606060" id="lnum62"> 62:</span> ,<span style="color: #006080">' <li>'</span> |
1 |
<span style="color: #606060" id="lnum63"> 63:</span> ); |
1 |
<span style="color: #606060" id="lnum64"> 64:</span> <span style="color: #0000ff">if</span>(!$isEmptyString(itemContainerTitle)) |
1 |
<span style="color: #606060" id="lnum65"> 65:</span> { |
1 |
<span style="color: #606060" id="lnum66"> 66:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum67"> 67:</span> ,<span style="color: #006080">' <h3 class="cbs-diagnostic-ContainerTitle">'</span>, $htmlEncode(itemContainerTitle) ,<span style="color: #006080">'</h3>'</span> |
1 |
<span style="color: #606060" id="lnum68"> 68:</span> ); |
1 |
<span style="color: #606060" id="lnum69"> 69:</span> } |
1 |
<span style="color: #606060" id="lnum70"> 70:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum71"> 71:</span> ,<span style="color: #006080">' <ul id="'</span>, pictureSlotContainerId ,<span style="color: #006080">'" class="cbs-diagnosticSlot">'</span> |
1 |
<span style="color: #606060" id="lnum72"> 72:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticSlotName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_PictureSlot"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum73"> 73:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemProperty">'</span> |
1 |
<span style="color: #606060" id="lnum74"> 74:</span> ,<span style="color: #006080">' <ul class="cbs-diagnosticItemContainer">'</span> |
1 |
<span style="color: #606060" id="lnum75"> 75:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_Value"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum76"> 76:</span> ); |
1 |
<span style="color: #606060" id="lnum77"> 77:</span> <span style="color: #0000ff">if</span>(pictureURL.isEmpty) |
1 |
<span style="color: #606060" id="lnum78"> 78:</span> { |
1 |
<span style="color: #606060" id="lnum79"> 79:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum80"> 80:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">&#160;</li>'</span> |
1 |
<span style="color: #606060" id="lnum81"> 81:</span> ); |
1 |
<span style="color: #606060" id="lnum82"> 82:</span> } |
1 |
<span style="color: #606060" id="lnum83"> 83:</span> <span style="color: #0000ff">else</span> |
1 |
<span style="color: #606060" id="lnum84"> 84:</span> { |
1 |
<span style="color: #606060" id="lnum85"> 85:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum86"> 86:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">'</span>, $htmlEncode(pictureURL.value) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum87"> 87:</span> ); |
1 |
<span style="color: #606060" id="lnum88"> 88:</span> } |
1 |
<span style="color: #606060" id="lnum89"> 89:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum90"> 90:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum91"> 91:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum92"> 92:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemProperty">'</span> |
1 |
<span style="color: #606060" id="lnum93"> 93:</span> ,<span style="color: #006080">' <ul class="cbs-diagnosticItemContainer">'</span> |
1 |
<span style="color: #606060" id="lnum94"> 94:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_Preview"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum95"> 95:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">'</span> |
1 |
<span style="color: #606060" id="lnum96"> 96:</span> ,<span style="color: #006080">' <div class="cbs-picture3LinesImageContainer" id="'</span>, pictureContainerId ,<span style="color: #006080">'">'</span> |
1 |
<span style="color: #606060" id="lnum97"> 97:</span> ,<span style="color: #006080">' <a class="cbs-pictureImgLink" href="'</span>, linkURL ,<span style="color: #006080">'" title="'</span>, line1 ,<span style="color: #006080">'" id="'</span>, pictureLinkId ,<span style="color: #006080">'">'</span> |
1 |
<span style="color: #606060" id="lnum98"> 98:</span> ,<span style="color: #006080">' '</span>, pictureMarkup ,<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum99"> 99:</span> ,<span style="color: #006080">' </a>'</span> |
1 |
<span style="color: #606060" id="lnum100"> 100:</span> ,<span style="color: #006080">' </div>'</span> |
1 |
<span style="color: #606060" id="lnum101"> 101:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum102"> 102:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum103"> 103:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum104"> 104:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemProperty">'</span> |
1 |
<span style="color: #606060" id="lnum105"> 105:</span> ,<span style="color: #006080">' <ul class="cbs-diagnosticItemContainer">'</span> |
1 |
<span style="color: #606060" id="lnum106"> 106:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_MappedManagedProperty"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum107"> 107:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">'</span>, $htmlEncode(pictureURL.managedPropertyName) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum108"> 108:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum109"> 109:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum110"> 110:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemProperty">'</span> |
1 |
<span style="color: #606060" id="lnum111"> 111:</span> ,<span style="color: #006080">' <ul class="cbs-diagnosticItemContainer">'</span> |
1 |
<span style="color: #606060" id="lnum112"> 112:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_PropertyMappings"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum113"> 113:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">'</span>, cbsDiagnostic_RenderPropertyMappings(pictureURL) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum114"> 114:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum115"> 115:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum116"> 116:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum117"> 117:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum118"> 118:</span> ,<span style="color: #006080">' <li>'</span> |
1 |
<span style="color: #606060" id="lnum119"> 119:</span> ,<span style="color: #006080">' <ul id="'</span>, pathContainerId ,<span style="color: #006080">'" class="cbs-diagnosticSlot">'</span> |
1 |
<span style="color: #606060" id="lnum120"> 120:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticSlotName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_PathSlot"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum121"> 121:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemProperty">'</span> |
1 |
<span style="color: #606060" id="lnum122"> 122:</span> ,<span style="color: #006080">' <ul class="cbs-diagnosticItemContainer">'</span> |
1 |
<span style="color: #606060" id="lnum123"> 123:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_Value"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum124"> 124:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">'</span>, $htmlEncode(linkURL.value) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum125"> 125:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum126"> 126:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum127"> 127:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum128"> 128:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum129"> 129:</span> ); |
1 |
<span style="color: #606060" id="lnum130"> 130:</span> <span style="color: #0000ff">for</span>(<span style="color: #0000ff">var</span> lineNum = 1; lineNum <= 10; lineNum++) |
1 |
<span style="color: #606060" id="lnum131"> 131:</span> { |
1 |
<span style="color: #606060" id="lnum132"> 132:</span> <span style="color: #0000ff">var</span> lineValueInfo = $getItemValue(ctx, String.format(<span style="color: #006080">"Line {0}"</span>, lineNum)); |
1 |
<span style="color: #606060" id="lnum133"> 133:</span> <span style="color: #0000ff">if</span>(!$isNull(lineValueInfo) && !$isEmptyString(cbsDiagnostic_RenderPropertyMappings(lineValueInfo))) |
1 |
<span style="color: #606060" id="lnum134"> 134:</span> { |
1 |
<span style="color: #606060" id="lnum135"> 135:</span> <span style="color: #0000ff">var</span> lineId = String.format(<span style="color: #006080">"{0}line{1}"</span>, encodedId, lineNum); |
1 |
<span style="color: #606060" id="lnum136"> 136:</span> <span style="color: #0000ff">var</span> slotName = String.format($resource(<span style="color: #006080">"item_Diagnostic_SlotNameFormat"</span>), lineNum); |
1 |
<span style="color: #606060" id="lnum137"> 137:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum138"> 138:</span> ,<span style="color: #006080">' <li>'</span> |
1 |
<span style="color: #606060" id="lnum139"> 139:</span> ,<span style="color: #006080">' <ul id="'</span>, lineId ,<span style="color: #006080">'" class="cbs-diagnosticSlot">'</span> |
1 |
<span style="color: #606060" id="lnum140"> 140:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticSlotName">'</span>, $htmlEncode(slotName) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum141"> 141:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemProperty">'</span> |
1 |
<span style="color: #606060" id="lnum142"> 142:</span> ,<span style="color: #006080">' <ul class="cbs-diagnosticItemContainer">'</span> |
1 |
<span style="color: #606060" id="lnum143"> 143:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_Value"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum144"> 144:</span> ); |
1 |
<span style="color: #606060" id="lnum145"> 145:</span> <span style="color: #0000ff">if</span>(lineValueInfo.isEmpty) |
1 |
<span style="color: #606060" id="lnum146"> 146:</span> { |
1 |
<span style="color: #606060" id="lnum147"> 147:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum148"> 148:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">&#160;</li>'</span> |
1 |
<span style="color: #606060" id="lnum149"> 149:</span> ); |
1 |
<span style="color: #606060" id="lnum150"> 150:</span> } |
1 |
<span style="color: #606060" id="lnum151"> 151:</span> <span style="color: #0000ff">else</span> |
1 |
<span style="color: #606060" id="lnum152"> 152:</span> { |
1 |
<span style="color: #606060" id="lnum153"> 153:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum154"> 154:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">'</span>, lineValueInfo ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum155"> 155:</span> ); |
1 |
<span style="color: #606060" id="lnum156"> 156:</span> } |
1 |
<span style="color: #606060" id="lnum157"> 157:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum158"> 158:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum159"> 159:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum160"> 160:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemProperty">'</span> |
1 |
<span style="color: #606060" id="lnum161"> 161:</span> ,<span style="color: #006080">' <ul class="cbs-diagnosticItemContainer">'</span> |
1 |
<span style="color: #606060" id="lnum162"> 162:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_MappedManagedProperty"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum163"> 163:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">'</span>, $htmlEncode(lineValueInfo.managedPropertyName) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum164"> 164:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum165"> 165:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum166"> 166:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemProperty">'</span> |
1 |
<span style="color: #606060" id="lnum167"> 167:</span> ,<span style="color: #006080">' <ul class="cbs-diagnosticItemContainer">'</span> |
1 |
<span style="color: #606060" id="lnum168"> 168:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemName">'</span>, $htmlEncode($resource(<span style="color: #006080">"item_Diagnostic_PropertyMappings"</span>)) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum169"> 169:</span> ,<span style="color: #006080">' <li class="cbs-diagnosticItemValue">'</span>, cbsDiagnostic_RenderPropertyMappings(lineValueInfo) ,<span style="color: #006080">'</li>'</span> |
1 |
<span style="color: #606060" id="lnum170"> 170:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum171"> 171:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum172"> 172:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum173"> 173:</span> ,<span style="color: #006080">' </li>'</span> |
1 |
<span style="color: #606060" id="lnum174"> 174:</span> ); |
1 |
<span style="color: #606060" id="lnum175"> 175:</span> } |
1 |
<span style="color: #606060" id="lnum176"> 176:</span> } |
1 |
<span style="color: #606060" id="lnum177"> 177:</span> ms_outHtml.push(<span style="color: #006080">''</span> |
1 |
<span style="color: #606060" id="lnum178"> 178:</span> ,<span style="color: #006080">' </ul>'</span> |
1 |
<span style="color: #606060" id="lnum179"> 179:</span> ,<span style="color: #006080">' '</span> |
1 |
<span style="color: #606060" id="lnum180"> 180:</span> ); |
1 |
<span style="color: #606060" id="lnum181"> 181:</span> |
1 |
<span style="color: #606060" id="lnum182"> 182:</span> ctx[<span style="color: #006080">'ItemValues'</span>] = cachePreviousItemValuesFunction; |
1 |
<span style="color: #606060" id="lnum183"> 183:</span> ctx[<span style="color: #006080">'DisplayTemplateData'</span>] = cachePreviousTemplateData; |
1 |
<span style="color: #606060" id="lnum184"> 184:</span> <span style="color: #0000ff">return</span> ms_outHtml.join(<span style="color: #006080">''</span>); |
1 |
<span style="color: #606060" id="lnum185"> 185:</span> } |
1 |
<span style="color: #606060" id="lnum186"> 186:</span> <span style="color: #0000ff">function</span> RegisterTemplate_6be7c3604a7e4519a210e962b4ed867c() {ULScqk:; |
1 |
<span style="color: #606060" id="lnum187"> 187:</span> |
1 |
<span style="color: #606060" id="lnum188"> 188:</span> <span style="color: #0000ff">if</span> (<span style="color: #006080">"undefined"</span> != <span style="color: #0000ff">typeof</span> (Srch) &&<span style="color: #006080">"undefined"</span> != <span style="color: #0000ff">typeof</span> (Srch.U) &&<span style="color: #0000ff">typeof</span>(Srch.U.registerRenderTemplateByName) == <span style="color: #006080">"function"</span>) { |
1 |
<span style="color: #606060" id="lnum189"> 189:</span> Srch.U.registerRenderTemplateByName(<span style="color: #006080">"Item_Diagnostic"</span>, DisplayTemplate_6be7c3604a7e4519a210e962b4ed867c); |
1 |
<span style="color: #606060" id="lnum190"> 190:</span> } |
1 |
<span style="color: #606060" id="lnum191"> 191:</span> |
1 |
<span style="color: #606060" id="lnum192"> 192:</span> <span style="color: #0000ff">if</span> (<span style="color: #006080">"undefined"</span> != <span style="color: #0000ff">typeof</span> (Srch) &&<span style="color: #006080">"undefined"</span> != <span style="color: #0000ff">typeof</span> (Srch.U) &&<span style="color: #0000ff">typeof</span>(Srch.U.registerRenderTemplateByName) == <span style="color: #006080">"function"</span>) { |
1 |
<span style="color: #606060" id="lnum193"> 193:</span> Srch.U.registerRenderTemplateByName(<span style="color: #006080">"~sitecollectionu002f_catalogsu002fmasterpageu002fDisplay Templatesu002fSearchu002fItem_Diagnostic.js"</span>, DisplayTemplate_6be7c3604a7e4519a210e962b4ed867c); |
1 |
<span style="color: #606060" id="lnum194"> 194:</span> } |
1 |
<span style="color: #606060" id="lnum195"> 195:</span> |
1 |
<span style="color: #606060" id="lnum196"> 196:</span> $includeLanguageScript(<span style="color: #006080">"~sitecollectionu002f_catalogsu002fmasterpageu002fDisplay Templatesu002fSearchu002fItem_Diagnostic.js"</span>, <span style="color: #006080">"~sitecollection/_catalogs/masterpage/Display Templates/Language Files/{Locale}/CustomStrings.js"</span>); |
1 |
<span style="color: #606060" id="lnum197"> 197:</span> |
1 |
<span style="color: #606060" id="lnum198"> 198:</span> } |
1 |
<span style="color: #606060" id="lnum199"> 199:</span> RegisterTemplate_6be7c3604a7e4519a210e962b4ed867c(); |
1 |
<span style="color: #606060" id="lnum200"> 200:</span> <span style="color: #0000ff">if</span> (<span style="color: #0000ff">typeof</span>(RegisterModuleInit) == <span style="color: #006080">"function"</span> && <span style="color: #0000ff">typeof</span>(Srch.U.replaceUrlTokens) == <span style="color: #006080">"function"</span>) { |
1 |
<span style="color: #606060" id="lnum201"> 201:</span> RegisterModuleInit(Srch.U.replaceUrlTokens(<span style="color: #006080">"~sitecollectionu002f_catalogsu002fmasterpageu002fDisplay Templatesu002fSearchu002fItem_Diagnostic.js"</span>), RegisterTemplate_6be7c3604a7e4519a210e962b4ed867c); |
1 |
<span style="color: #606060" id="lnum202"> 202:</span> } |
And finally, if you are working with image renditions, you can provisioning your renditions using server side code, like Waldek shows in his article, and even tough I have not try it, it should work on sandbox, but also, you can do it declaratively, deploying the file “PublishingImageRenditions.xml” to the Master page gallery using a Module.
The “PublishingImageRenditions.xml” looks like that:
1 |
<span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff"><</span><span style="color: #800000">SiteImageRenditions</span> <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://schemas.datacontract.org/2004/07/Microsoft.SharePoint.Publishing"</span> <span style="color: #ff0000">xmlns:i</span><span style="color: #0000ff">="http://www.w3.org/2001/XMLSchema-instance"</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum2"> 2:</span> <span style="color: #0000ff"><</span><span style="color: #800000">NextId</span><span style="color: #0000ff">></span>6<span style="color: #0000ff"></</span><span style="color: #800000">NextId</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Renditions</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum4"> 4:</span> <span style="color: #0000ff"><</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum5"> 5:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span>120<span style="color: #0000ff"></</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum6"> 6:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span>5<span style="color: #0000ff"></</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum7"> 7:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span>My custom rendition<span style="color: #0000ff"></</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum8"> 8:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span>1<span style="color: #0000ff"></</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum9"> 9:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span>190<span style="color: #0000ff"></</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum10"> 10:</span> <span style="color: #0000ff"></</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum11"> 11:</span> <span style="color: #0000ff"><</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum12"> 12:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span>100<span style="color: #0000ff"></</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum13"> 13:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span>1<span style="color: #0000ff"></</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum14"> 14:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span>Display Template Picture 3 Lines<span style="color: #0000ff"></</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum15"> 15:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span>1<span style="color: #0000ff"></</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum16"> 16:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span>100<span style="color: #0000ff"></</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum17"> 17:</span> <span style="color: #0000ff"></</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum18"> 18:</span> <span style="color: #0000ff"><</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum19"> 19:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span>100<span style="color: #0000ff"></</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum20"> 20:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span>2<span style="color: #0000ff"></</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum21"> 21:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span>Display Template Picture On Top<span style="color: #0000ff"></</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum22"> 22:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span>1<span style="color: #0000ff"></</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum23"> 23:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span>304<span style="color: #0000ff"></</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum24"> 24:</span> <span style="color: #0000ff"></</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum25"> 25:</span> <span style="color: #0000ff"><</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum26"> 26:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span>220<span style="color: #0000ff"></</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum27"> 27:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span>3<span style="color: #0000ff"></</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum28"> 28:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span>Display Template Large Picture<span style="color: #0000ff"></</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum29"> 29:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span>1<span style="color: #0000ff"></</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum30"> 30:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span>468<span style="color: #0000ff"></</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum31"> 31:</span> <span style="color: #0000ff"></</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum32"> 32:</span> <span style="color: #0000ff"><</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum33"> 33:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span>68<span style="color: #0000ff"></</span><span style="color: #800000">Height</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum34"> 34:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span>4<span style="color: #0000ff"></</span><span style="color: #800000">Id</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum35"> 35:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span>Display Template Video<span style="color: #0000ff"></</span><span style="color: #800000">Name</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum36"> 36:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span>1<span style="color: #0000ff"></</span><span style="color: #800000">Version</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum37"> 37:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span>120<span style="color: #0000ff"></</span><span style="color: #800000">Width</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum38"> 38:</span> <span style="color: #0000ff"></</span><span style="color: #800000">ImageRendition</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum39"> 39:</span> <span style="color: #0000ff"></</span><span style="color: #800000">Renditions</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum40"> 40:</span> <span style="color: #0000ff"></</span><span style="color: #800000">SiteImageRenditions</span><span style="color: #0000ff">></span> |
My advice is that you create your image renditions using the User Interface, and then download the file and add it to your Visual Studio Module. If you edit the file manually, take care with the node “NextId” !!
The module for the xml file would be:
1 |
<span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Elements</span> <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://schemas.microsoft.com/sharepoint/"</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum2"> 2:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Module</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">="MO_ImageRenditions"</span> <span style="color: #ff0000">Url</span><span style="color: #0000ff">="_catalogs/masterpage"</span> <span style="color: #ff0000">RootWebOnly</span><span style="color: #0000ff">="TRUE"</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #0000ff"><</span><span style="color: #800000">File</span> <span style="color: #ff0000">Path</span><span style="color: #0000ff">="MO_ImageRenditionsPublishingImageRenditions.xml"</span> <span style="color: #ff0000">Url</span><span style="color: #0000ff">="PublishingImageRenditions.xml"</span> <span style="color: #ff0000">Type</span><span style="color: #0000ff">="GhostableInLibrary"</span> <span style="color: #ff0000">Level</span><span style="color: #0000ff">="Published"</span> <span style="color: #ff0000">ReplaceContent</span><span style="color: #0000ff">="true"</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum4"> 4:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Property</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">="ContentTypeId"</span> <span style="color: #ff0000">Value</span><span style="color: #0000ff">="0x01010012BCF119622FF14793A8A38D5831F25C"</span> <span style="color: #0000ff">/></span> |
1 |
<span style="color: #606060" id="lnum5"> 5:</span> <span style="color: #0000ff"><</span><span style="color: #800000">Property</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">="ContentType"</span> <span style="color: #ff0000">Value</span><span style="color: #0000ff">="Document"</span> <span style="color: #0000ff">/></span> |
1 |
<span style="color: #606060" id="lnum6"> 6:</span> <span style="color: #0000ff"></</span><span style="color: #800000">File</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum7"> 7:</span> <span style="color: #0000ff"></</span><span style="color: #800000">Module</span><span style="color: #0000ff">></span> |
1 |
<span style="color: #606060" id="lnum8"> 8:</span> <span style="color: #0000ff"></</span><span style="color: #800000">Elements</span><span style="color: #0000ff">></span> |
And that’s all, with this, your display template will show an image using the desired rendition.
Hope it helps, and let me know any comment.
Luis Manez
@luismanez
Deja un comentario