Copied to clipboard

Flag this post as spam?

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


  • Tom Maton 387 posts 660 karma points
    Sep 09, 2009 @ 13:30
    Tom Maton
    0

    Error when getting media images

     

    Hi All,

    I am trying to get all the Media images and then get the data alias company name and match that to a variable. But I am failing at the first hurdle, I cant even get all the images which reside in the media section

    This my current code

      <xsl:template match="/">
    <xsl:for-each select="umbraco.library:GetMedia(./data [@nodeTypeAlias = 'Image'],'false')/data">

    </xsl:for-each>
    </xsl:template>

    This is the error I am getting

    System.OverflowException: Value was either too large or too small for an Int32.
    

    Any help greatly appreciated

    Thanks

    Tom

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 09, 2009 @ 13:52
    Dirk De Grave
    0

    Tom,

    Do you get the error when saving the xslt? If so, it's due to the fact that your for-each does not necessarily hold a value (xslt's are checked against a node when saving - but it's not garantueed that node  - think it's the top level node - has a value for that property)

    Anyway, it's best practise to surround with an xsl:if statement to avoid the runtime error.

    <xsl:if test="string-length(./data [@alias = 'Image']) &gt; 0">
      <!-- your for-each code -->
    </xsl:if>

    Hope this helps.

    Regards,

    /Dirk

     

  • Tom Maton 387 posts 660 karma points
    Sep 09, 2009 @ 14:55
    Tom Maton
    0

    Cheers Dirk

    And thanks for the advice on best practices.

    Tom

Please Sign in or register to post replies

Write your reply to:

Draft