yuyu
yuyu

Reputation: 144

Is it possible to retrieve the latest uploaded asset rendition in AEM?

For my video assets, I want to set my own thumbnails by adding a new rendition on assets. I am able to retrieve all the renditions uploaded using the getRenditions method however, I want to retrieve the path for the latest uploaded rendition only.

Upvotes: 1

Views: 456

Answers (1)

Volo Myhal
Volo Myhal

Reputation: 144

My suggestion is to iterate Asset's Renditions and find the latest one, looking at "jcr:lastModified" property, here is untested code sample:

          Rendition lastRendition = null;
          Date lastDate = null;
          for (Rendition r : asset.getRenditions()) {
              Date date = r.getProperties().get(JcrConstants.JCR_LASTMODIFIED);
              if (lastDate == null || date.after(lastDate)) {
                 lastRendition = r;
                 lastDate = date;
              }
          } 

Upvotes: 1

Related Questions