Image Modified Date

webteam's Avatar

webteam

01 Mar, 2016 05:09 PM

When using an index block of the current page, is it possible to get the last modified date of any image used on the page? This way we could use it to break caches?

  1. 1 Posted by Ryan Griffith on 01 Mar, 2016 07:39 PM

    Ryan Griffith's Avatar

    Hi,

    Unless your image is coming from a file chooser in the page's Data Definition, it might be a little difficult to accomplish this.

    If the image is within a WYSIWYG field, one idea that comes to mind is to somehow parse for all <img> tags, grab the file path from the src attribute, use the Locator Tool to read in the File asset, and rewrite the link based on the returned File object's last modified date. Definitely just an idea, I am not sure how simple that would be or if it's even possible.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by Matthew Ferdere... on 01 Mar, 2016 08:48 PM

    Matthew Ferderer's Avatar

    Ryan,

    What setting am I missing to make it easy to accomplish with a file chooser? I’m guessing I need to check a box on the index block?

  3. 3 Posted by Ryan Griffith on 01 Mar, 2016 09:13 PM

    Ryan Griffith's Avatar

    Hi Matthew,

    Chooser fields themselves won't include this information, but what you can do is use the site and path information in conjunction with the Locator Tool to read the asset and get it's last modified date.

    Note: the Locator Tool will return a Date object, so you will need to use the Date#getTime() method to get the timestamp if that's what you need.

    Please let me know if you have any questions.

    Thanks!

  4. 4 Posted by Matthew Ferdere... on 01 Mar, 2016 09:23 PM

    Matthew Ferderer's Avatar

    Thanks Ryan. That helps.

  5. 5 Posted by Ryan Griffith on 01 Mar, 2016 09:37 PM

    Ryan Griffith's Avatar

    Not a problem at all, Matthew. I am glad to hear I was able to point you in the right direction.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  6. Ryan Griffith closed this discussion on 01 Mar, 2016 09:37 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM