Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Nov 22, 2013 @ 11:16
    Claushingebjerg
    0

    Getting ALL images from media library

    I need to list all images from the media library. I know you think why? But i just need to :)
    Seeing as the media library root node doesnt seem to have an id,im a bit lost
    Im trying to start in a folder, work my way to the root, and then down again by:

    <xsl:for-each select="umbraco.library:GetMedia(1279, 1)/ancestor-or-self::*/descendant-or-self::*/Image" >

    But it only gets me the images from the current folder for some reason...

    Any help appreciated.

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Nov 22, 2013 @ 13:03
    Chriztian Steinmeier
    1

    Hi Claus,

    That's actually not possible (as you found out) - the XML you get back does not have the full context, so you need a little help... and uComponents is your friend (as always :-)

    Checkout this extension: GetMediaByXPath()

    I hit the same "wall" in my LatestEditsDashboard package and found that gem - but it requires uComponents of course, which may not be a real problem :-)

    So you should be able to do this:

    <xsl:for-each select="ucomponents.media:GetMediaByXPath('/')//Image" >
      <!-- stuff -->
    </xsl:for-each>
    

    If you need a fallback for when uComponents isn't available, check the source code here for how I do that.

    /Chriztian

  • Claushingebjerg 939 posts 2574 karma points
    Nov 22, 2013 @ 13:50
    Claushingebjerg
    0

    AWESOME!

    H7UR ;)

Please Sign in or register to post replies

Write your reply to:

Draft