Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Jul 21, 2011 @ 04:27
    syn-rg
    0

    Image gallery thumbnails add css class if "new" image

    How can I add a CSS class to an Image gallery thumbnail, if the image is a recent or new image uploaded to the gallery?

    I want to add a CSS class "new" to the image, and have that appear on the image for 60 days.
    Is there a way of doing this using the publish date?
    I'm guessing some jQuery or C# code will be needed to work out the 60 days functionality.

    Can anyone suggest some ideas?

    Cheers,
    JV

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jul 21, 2011 @ 04:53
    Tom Fulton
    0

    umbraco.library has some built in Date functions you can use for this, DateDiff should help you.  Just took a quick look, and with some help from this thread, the below should work.  Couldn't figure out how to get it to return days, but you get the idea :)

    <img ...>
        <xsl:if test="(umbraco.library:DateDiff(umbraco.library:CurrentDate(),$media/@createDate, 'm') div 1440) &lt; 60">
          <xsl:attribute name="class">new</xsl:attribute>
        </xsl:if>
      </img>

    ... where $media is a variable with the current media node XML.

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft