Copied to clipboard

Flag this post as spam?

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


  • Craig 2 posts 22 karma points
    Oct 14, 2011 @ 23:26
    Craig
    0

    Schoolboy error or is something wrong with my output?

    I’m using Umbraco 4.7.0

    My goal is to get the image path from a hard coded media node id of 4191. If I create a new macro with the code:

    <xsl:copy-of select="umbraco.library:GetMedia(4191, false())"/>

    I get the output:

    /media/17675/my image.jpg50033618497jpg

    I was expecting some well formed xml, however, it appears I’m missing all the tags. I therefore cannot reference the path for the image directly.

    Am I missing something really simple here?

  • bob baty-barr 1180 posts 1294 karma points MVP
    Oct 15, 2011 @ 00:32
    bob baty-barr
    1

    are you putting the output in a textarea? or viewing the source output of the page?

    you can actually get the image path by using

    <xsl:vaule-of select="umbraco.library:GetMedia(4191,false())/umbracoFile"/>

    You can then use something like this to actually render the image in your html

    <xsl:variable name="picFile" select="umbraco.library:GetMedia(4191,false())/umbracoFile"/>
    <xsl:if test="$picFile != '' ">
    <img src="{$picFile}"/>
    </xsl:if>
  • Craig 2 posts 22 karma points
    Oct 15, 2011 @ 07:46
    Craig
    0

    Thank you bob baty-barr

    I discovered how to get the raw xml output from my `copy-of` statement. I needed to wrap it in a `<textarea>` tag:  

      <textarea>
         
    <xsl:copy-ofselect="umbraco.library:GetMedia(4191, false())"/>
    </textarea>

    Thank to this post

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies