是否可以在 AEM 中检索最新上传的资产演绎版?

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

对于我的视频资产,我想通过在资产上添加新的再现来设置我自己的缩略图。我能够检索使用 getRenditions 方法上传的所有演绎版,但是,我只想检索最新上传的演绎版的路径。

我的建议是迭代资产的演绎版并找到最新的演绎版,查看“jcr:lastModified”属性,这是未经测试的代码示例:

          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;
              }
          }