Copied to clipboard

Flag this post as spam?

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


  • Paul Griffiths 370 posts 1021 karma points
    Jul 05, 2013 @ 17:09
    Paul Griffiths
    0

    Help with rendering images

    Hi guys im a complete newbie with xslt but im wondering if anyone could help me.

    I have an perfectly good xslt macro that renders a news list like so

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/* [@isDoc]">
        <xsl:sort select="@createDate" order="descending"/>
        <xsl:if test="position() &lt;= $maxItems">
        <li>
            <h3>
                <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="pageImage"/>   <---------------------------------
                <xsl:value-of select="newsHeadline"/>
                   
                </a>
            </h3>
            <p><xsl:value-of select="newsTeaserText" /></p>
            <small>Created by: <xsl:value-of select="@writerName"/> on <xsl:value-of select="umbraco.library:LongDate(@createDate)"/> </small>
           
        </li>
        </xsl:if>
    </xsl:for-each>

    However im trying to render an image into the produced list that has the alias pageImage. I add the line of code that I have bolded and marked with an arrow and instead of an image rendering i get this.../media/1004/luis.jpg

    I just thought it would be a case of adding xsl:value of similar to how i have targeted other umbraco page fields.

    Thanks for the help in advance

    Paul

  • Niels Lynggaard 193 posts 551 karma points
    Jul 05, 2013 @ 17:57
    Niels Lynggaard
    1

    use umbraco.library:getmedia() like this:

    <xsl:variablename="media"select="umbraco.library:GetMedia($currentPage/pageImage, 0)"/>

     
    <xsl:iftest="$media">
     
    <xsl:variablename="url"select="$media/umbracoFile"/>
       
    <xsl:variablename="width"select="$media/umbracoWidth"/>
         
    <xsl:variablename="height"select="$media/umbracoHeight"/>
       
    <imgsrc="{$url}"width="{$width}"height="{$height}"/>
     
    </xsl:if>

     

    Depending on what version of the schema your're using the syntax is a little different.

    Check out the docs here:

    http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

     

     

  • Paul Griffiths 370 posts 1021 karma points
    Jul 05, 2013 @ 20:50
    Paul Griffiths
    0

    Thanks for your reply niels, I will give it a go and let you know how I do

    Paul

  • 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