Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mike Livermore 6 posts 26 karma points
    Aug 14, 2009 @ 21:54
    Mike Livermore
    0

    Showing Image from Template using inline xslt

    I am just trying to display media picker images from a template it only displays when using hardcoded Node Id:

    This works and displays the image:

     xslt="concat('<img src="', umbraco.library:GetMedia(1949,'true')/ data[@alias='umbracoFile'], '" />')"
     XsltDisableEscaping="true"

    But this doesn't (given property name PageHeaderImage for the template):

     xslt="concat('<img src="', umbraco.library:GetMedia([#PageHeaderImage],'true')/ data[@alias='umbracoFile'], '" />')"
     XsltDisableEscaping="true"

    Does anyone know how to insert the current property value (image node id) to get the image to display?  Or do I have to use a macro instead of using inline xslt?

    Any help would be appreciated!

    Thanks,

    Mike

  • Chris Koiak 700 posts 2626 karma points
    Aug 14, 2009 @ 22:41
    Chris Koiak
    0

    You'll have to do this in a custom xslt. Usually it's better writting this in an xslt as you can check if the page property PageHeaderImage is valid or not.

    You could always use the inline xslt functionality of http://our.umbraco.org/projects/xsltresult to achieve this directly in the template.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 14, 2009 @ 23:09
    Morten Bock
    1

    Mike

    Take a look at the samples in this book:

    http://umbraco.org/documentation/books/inline-xslt

    <umbraco:Item runat="server" field="PageHeaderImage"
    xslt="concat('&lt;img src=&quot;', umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')"
    xsltDisableEscaping="true" />
    

    That should get you going :-)

  • Mike Livermore 6 posts 26 karma points
    Aug 19, 2009 @ 17:19
    Mike Livermore
    0

    Thanks to both of you.  Chris, I took your advice and did it in a macro.  We aren't ready to start adding extension projects yet but later I may look at using your inline xslt project..

  • Matthew Jarvis 129 posts 129 karma points
    Feb 06, 2012 @ 16:51
    Matthew Jarvis
    0

    Hey guys,

    I currently have

     <umbraco:Item runat="server" field="pageRotatorImage1" xslt="concat('&lt;img src=&quot;', umbraco.library:GetMedia({0}, true())/umbracoFile,'&quot; /&gt;')" xsltDisableEscaping="true"/>

    How would I go about getting an alt attribute within this piece of code.  Details for this alt currently sit within an alt item with an alias 'alt text' within my media folder.

     

     

     

     

     

     

     

  • Luciano Spilotros 1 post 21 karma points
    Sep 07, 2012 @ 17:27
    Luciano  Spilotros
    0

    Hello guys,

    I am new to Umbraco and I am trying to get an image in a template. Unfortunately none of the solutions suggested above worked...this is what I have in my template code:

    <span style="color: green"><umbraco:Item field="newsImage" runat="server"/></span>
           
    <umbraco:Item runat="server" field="newsImage"
    xslt="concat('&lt;img src=&quot;', umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')"
    xsltDisableEscaping="true" />

     

    And that is what is rendered in my browser: 

    <span style="color: green">1231</span>
    <img src="">

     

    As you can see the field parameter is exstisting but something goes wrong when returning the image url.

    Is there anything I am missing? 

    Thanks

     

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Sep 12, 2012 @ 09:24
    Morten Bock
    0

    You are probably using the new xml schema, so I think your code should be:

    <spanstyle="color: green"><umbraco:Itemfield="newsImage"runat="server"/></span>
           
    <umbraco:Itemrunat="server"field="newsImage"
    xslt="concat('&lt;img src=&quot;', umbraco.library:GetMedia({0},'false')/umbracoFile, '&quot; /&gt;')"
    xsltDisableEscaping="true"/>

    Hope this helps

Please Sign in or register to post replies

Write your reply to:

Draft