Copied to clipboard

Flag this post as spam?

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


  • Eran 292 posts 436 karma points
    Apr 25, 2010 @ 04:59
    Eran
    0

    get the last 10 updated images from the media folder

    hello,

    i'm using this recursive macro to display my images from the media folder (that the user picked using the media picker):

    the problem is that i want to display only the last 10 images that the user updated.

    how can i do that?

    thanks!

    Eran.

     

  • bob baty-barr 1180 posts 1294 karma points MVP
    Apr 25, 2010 @ 20:12
    bob baty-barr
    0

    in one of my sites, i allow a user to specify how many of the 'latest' images in their upload folder they want to show... basically, sorting on createDate and checking position... hope this is helpful...

    <!-- start writing XSLT -->
    <xsl:variable name="showLatest" select="$currentPage/data[@alias='showLatest']"/>
    <xsl:if test="$currentPage/data [@alias = 'myPics'] != ''">
    <div id="myPics" class="round_this">
    <p class="header">my latest pics...</p>
    <div id="myPicsFader">
    <xsl:variable name="images" select="number($currentPage/data [@alias = 'myPics'])"/>
    <xsl:if test="$images != 0">
        <xsl:for-each select="umbraco.library:GetMedia($images, 'true')/node/node[@nodeTypeAlias='Image']">
        <xsl:sort select="@createDate" order="descending"/>
        <xsl:if test="position() &lt;= $showLatest">
            <xsl:variable name="picFile" select="./data[@alias='umbracoFile']"/>
            <div class="picSlide">
            <p style="text-align: center;">
            <img>
                <xsl:attribute name="src">/umbraco/imageGen.aspx?image=<xsl:value-of select="$picFile"/>&amp;width=210&amp;constrain=true</xsl:attribute>
                       
            </img>
            </p>
            </div>
        </xsl:if>
    </xsl:for-each>
    </xsl:if>
    </div>
    </div>
    </xsl:if>

  • Eran 292 posts 436 karma points
    Apr 26, 2010 @ 04:14
    Eran
    0

    thanks, thats works for me. by the way, i used updateDate instead of createDate.

    by the way, i asked it before but i didnt get any answer -

    when we are in the foreach loop and:

    <xsl:if test="position() &lt;= $showLatest">

    is false - it exits from the loop right away or continue to loop through all the items? (and dont enter the if statment).

    if the answer is yes, do we have a way to end the foreach loop when the above if statment is false?

    thanks!

    Eran.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Apr 26, 2010 @ 18:32
    bob baty-barr
    0

    wow, good question... not sure how xslt handles that type of element... i would guess it keeps looping and checking... which would not be good for performance i would think...

    thanks for the karma!

  • Kevin Farrow 46 posts 67 karma points
    Apr 26, 2010 @ 21:08
    Kevin Farrow
    1

    It will stay in the loop but...

    In actual fact it isn't really a sequential loop, and that is the reason you can't have xsl:continue or xsl:break

    XSLT is set based and not sequential therefore the n'th node isnt always processed before the n+1'th node; to all intent and purpose, the nodes are processed in parallel.

    Hope that helps....

    Kevin

  • dillorscroft 198 posts 192 karma points
    Apr 27, 2010 @ 01:17
    dillorscroft
    1

    Sebastian's Cultiv.Media cache is a direct replacement for umbraco.library:GetMedia and will speed up accessing media files as by default they aren't cached.

    [Edit] - I'm pretty sure Bob's a fan of this already but thought I'd let Eran know.

  • Eran 292 posts 436 karma points
    Apr 27, 2010 @ 01:43
    Eran
    0

    thanks all about the info and dillorscroft about the Cultiv.Media tip..

    is anyone experience real performence benefit after using Cultiv.Media package?

    Eran.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Apr 28, 2010 @ 04:54
    bob baty-barr
    0

    i am a fan of the media cache :) sorry i forgot to refrence it!

Please Sign in or register to post replies

Write your reply to:

Draft