Is it possible to search for a rendition of an image based on the dimensions via QueryBuilder API

RobertoPrimo

27-03-2020

Hi all,

 

What I would like to achieve is the following. Based on the specified dimension and an asset title I would like to find all the asset renditions which correspond to the search criteria. 

Currently I am using the QueryBuilder API as I am not working in Java but it seems impossible that in just one call to the AEM I manage to get the wanted rendition.

 

What would be the best way for search the image renditions?

Looking forward to your ideas!

Accepted Solutions (0)

Answers (1)

Answers (1)

davidjgonzalezz

20-10-2020

You cannot do this OOTB since rendition dimensions are not sorted as properties.

 

Technically could search for rendition nt:files, create a custom QueryBuilderFiltering predicate that pulls them into memory and determines their size and filters them in/out - but needless to say this would be very very bad for performance -- so don't do this!

 

Instead, I suggest creating a WF Process (assuming 6.x) that determines and writes rendition sizes as JCR Properties that you can then search over. There are main places you could put this data:

1) on the rendition [dam:Asset]/renditions/[nt:file]/[oak:resource] node - however this would require a custom mixin to allow you to put these custom properties - however you could apply them on each discrete rendition node.

2) under [dam:Asset]/metadata in some structure that holds the rendition dimensions, along w/ the rendition name.

 

Then make sure these new properties are indexed - and then use query builder to query on these derived rendition size properties.