Copied to clipboard

Flag this post as spam?

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


  • pawel 22 posts 42 karma points
    Jan 11, 2012 @ 21:02
    pawel
    0

    creating img tab from xslt

    hi guys,

    I am trying to pull some pictures from child elements using xslt, which I am not familiar of :( .

    basically documents have property "pictureUrl".  

    To list all the links to subpages I use built in template 'list subpages from current page' but alogside I would also like to show the pictures too. I can create pure list by using: <xsl:value-of select="pictureUrl"/> syntax but when I try to put it into <img src="#" /> I get some errors.

    Can you help?

    Thanks in advance.  

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Jan 11, 2012 @ 21:29
    Chriztian Steinmeier
    1

    Hi pawel,

    If you've created the pictureUrl property as a Media Picker, you need to use an extension method from the umbraco.library namespace, otherwise you shoud be able to just use curly-braces to get it in - try these:

    First - assume an upload field (or a URL textbox):

    <xsl:template match="/">
        <img src="{$currentPage/pictureUrl}" />
    </xsl:template>
    

    If that doesn't work, try this one - assumes a Media Picker was used:

    <xsl:template match="/">
        <!-- GetMedia() will complain if no image was picked, so need to check -->
        <xsl:if test="normalize-space($currentPage/pictureUrl)">
            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($currentPage/pictureUrl, false()" />
            <img src="{$mediaNode/umbracoFile}" width="{umbracoWidth}" height="{umbracoHeight}" alt="{@nodeName}" />
        </xsl:if>
    </xsl:template>

    /Chriztian

  • pawel 22 posts 42 karma points
    Jan 11, 2012 @ 22:34
    pawel
    0

    thanks a lot Chriztian,

    I use simple Textstring as a type and for some reason these solutions don't work....

    maybe it has something to do with umbraco version, it is an older one 4.5.2?

    regards,

  • pawel 22 posts 42 karma points
    Jan 11, 2012 @ 22:38
    pawel
    0

    I think I have it, I should simply have used

    <img src="{pictureUrl}" />

    :)

    Thanks again!

  • 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