Copied to clipboard

Flag this post as spam?

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


  • anthony hall 217 posts 530 karma points
    Apr 20, 2011 @ 14:04
    anthony hall
    0

    how to use getMedia without a foreach in 4.5

    I would like to create the following output

    <ul class="picture-slides-thumbnails">
    <li><href="/common/pictures/1.jpg"><img src="/common/thumbnails/1.jpg" alt="" /></a></li>
    </ul>

    My issue is that i current code i have to getMedia uses foreach and as there an "<a href=#>" that also has an image wrapping my image the foreach wouldn't work.What would be the best way to approach this. 

    Thanks. 

  • bob baty-barr 1180 posts 1294 karma points MVP
    Apr 20, 2011 @ 19:46
    bob baty-barr
    0

    1. determine if your property has a value - to avoid a getMedia() error...

    <xsl:if test="$currentPage/yourImageAlias != ''">

    then create a variable that equals the file path to the image

    <xsl:variable name="picFile" select="umbraco.library:GetMedia($currentPage/yourImagePropertyAlias,false)/umbracoFile"/>

    finally, set your image source...

    <img src="{$picFile}"/>

    don't forget to close your if test...

    </xsl:if>
  • 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