Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Content Fragment: Possible to use content reference element to pick image rendition? (AEM 6.4)

AEMRand
Level 2
Level 2

Hello, 

We have a set of content fragment templates with content reference fields that allow you to select images. 

Sample config: 

 

<imageField jcr:primaryType="nt:unstructured" sling:resourceType="dam/cfm/models/editor/components/contentreference"

fieldLabel="Image"
                            listOrder="21"
                            filter="hierarchy"
                            metaType="reference"
                            name="imageRef_image"
                            nameSuffix="contentReference"
                            renderReadOnly="false"
                            showEmptyInReadOnly="true"
                            valueType="string"/>

 

When interacting with this field, I can select the image just fine, but is there a way to select one of the image renditions (located at IMAGE/jcr:content/renditions/)? For some background, we have a servlet that returns content fragments as JSON. The image field on this response ends up being a reference to the original image, but we are trying to figure out a way to reference a particular resolution/rendition of the original. 

Interesting enough, if I select an image in the content reference field, and then add /jcr:content/renditions to the text field, the reference window will then show some of those available renditions. Just trying to figure out how to expose these by default. 

Thanks. 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
Pawan_Gupta_
Correct answer by
Community Advisor
Community Advisor

Hello,

I don't think OOTB it is possible. Now couple of thing you can do

 

1. if you deciding to root for image selection where the images renditions are a set and predefined, then you can create another drop down field (using that predefined set values) after image to select available available renditions. Now that data will be available in JSON to end application. at application side you can create the path through code like if the rendition drop down selected as 140x100 then through code you can create rendition path as "jcr:content/renditions/cq5dam.thumbnail.140.100.png" and suffixing to the image path. only maintenance would be managing the drop down if the rendition sizes change.

 

2. otherwise, you can write your own custom listener to prefetch available renditions under given image path and auto populate rest of the value as the author type. this would be more tricky as the list of renditions will grow 

 

Hope this helps!!

View solution in original post

2 Replies
Varun_Shakya
Community Advisor
Community Advisor

here is a similar thread

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-can-i-use-the-renditio...

See if that works for you,

Checked the component

/libs/dam/cfm/models/editor/components/contentreference

It comes under internal area so overlaying this component and making changes in it ..can not do this

 

if above solution does not works out, see if you could write any jquery code for that dialog and try to add "/jcr:content/renditions". As you told it worked for you . But this might not be the correct way,just a thought.

 

Pawan_Gupta_
Correct answer by
Community Advisor
Community Advisor

Hello,

I don't think OOTB it is possible. Now couple of thing you can do

 

1. if you deciding to root for image selection where the images renditions are a set and predefined, then you can create another drop down field (using that predefined set values) after image to select available available renditions. Now that data will be available in JSON to end application. at application side you can create the path through code like if the rendition drop down selected as 140x100 then through code you can create rendition path as "jcr:content/renditions/cq5dam.thumbnail.140.100.png" and suffixing to the image path. only maintenance would be managing the drop down if the rendition sizes change.

 

2. otherwise, you can write your own custom listener to prefetch available renditions under given image path and auto populate rest of the value as the author type. this would be more tricky as the list of renditions will grow 

 

Hope this helps!!

View solution in original post