Copied to clipboard

Flag this post as spam?

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


  • Ludvig 12 posts 33 karma points
    Mar 25, 2011 @ 12:34
    Ludvig
    0

    Get media problem

    hi

    I'm trying to fetch images from blogposts and and put the lates images on my startpage. I'm using umbraco 4.6.1 and I have some problems regarding GetMedia. here is the code:

    <xsl:variable name="mymediapicker">
    <xsl:value-of select="./data [@alias='mymediapicker']"/>
    </xsl:variable>
    <xsl:variable name="media" select="umbraco.library:GetMedia($mymediapicker, 0)" />
    <xsl:if test="$media">
    <img src="{$media/umbracoFile}" alt="{$media/altText}" />
    </xsl:if>

    the value of mymediapicker is for ex 1093 and there is no problem to print that. When I use mymediapicker in GetMedia I get an xslt error on page.
    If I replace $mymediapicker with my id 1093 everytihing works fine.  

    Why canĀ“t I put $mymediapicker in GetMedia?

  • Pasang Tamang 258 posts 458 karma points
    Mar 25, 2011 @ 12:46
    Pasang Tamang
    0

    You have to check either mymediapicker contains value or not.

    <xsl:variable name="mymediapicker">
    <xsl:value-of select="./data [@alias='mymediapicker']"/>
    </xsl:variable>
    <xsl:if test="string($mymediapicker) !=''">
    <img src="{umbraco.library:GetMedia($mymediapicker, 0)/umbracoFile}" alt="" />
    </xsl:if>

  • Ludvig 12 posts 33 karma points
    Mar 25, 2011 @ 12:59
    Ludvig
    0

    thats the core issue. When I print out $mymediapicker I do get results but when I use it the GetMedia an xslt error occur on the page...

  • Pasang Tamang 258 posts 458 karma points
    Mar 25, 2011 @ 13:04
  • Ludvig 12 posts 33 karma points
    Mar 25, 2011 @ 14:45
    Ludvig
    1

    thanks!

     

    here is my solution...

    <xsl:variable name="mymediapicker" select="$currentPage/data[@alias='mymediapicker']" />
          
          <xsl:if test="
    mymediapicker &gt; 0">
            <img src="{umbraco.library:GetMedia(number(
    mymediapicker), 0)/umbracoFile}" alt="umbraco.library:GetMedia(number(mymediapicker)/altText" />
          </xsl:if

    please feel free to comment

Please Sign in or register to post replies

Write your reply to:

Draft