Expand my Community achievements bar.

SOLVED

Rendition is missing in new Content Fragment Model

Avatar

Level 3

Previously, we used a Simple content fragment model(OOTB) to create CF and reading programmatically using the Original rendition created under each file. The 6.5.10 simple fragment model is deprecated, so we created a new Content fragment model that does not create renditions.

 

Is anyone know why it is not creating any renditions under file with the new Content fragment model?

 

With Simple fragment Model it is creating rendition -

ramaem12_1-1634551787086.png




With New custom content fragment model --

ramaem12_0-1634551757216.png

 



1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @ramaem12 ,

 

I am not sure on the renditions difference between two but i guess if you use Content Fragment API you just need a CF path to get its "Original" data.

 

//Get the resource of content fragment as below.
Resource fragmentResource = resourceResolver.getResource(“/content/dam/fragments/my-test-fragment”);

//Adapt it to a fragment resource
if (fragmentResource != null) {
ContentFragment fragment = fragmentResource.adaptTo(ContentFragment.class);
 Iterator<ContentElement> elements = fragment.getElements();
while (elements.hasNext()){
ContentElement element = elements.next();
} }

https://aemdeveloper.wordpress.com/2017/08/22/create-access-the-content-fragment-programmatically/

 

View solution in original post

6 Replies

Avatar

Correct answer by
Community Advisor

Hi @ramaem12 ,

 

I am not sure on the renditions difference between two but i guess if you use Content Fragment API you just need a CF path to get its "Original" data.

 

//Get the resource of content fragment as below.
Resource fragmentResource = resourceResolver.getResource(“/content/dam/fragments/my-test-fragment”);

//Adapt it to a fragment resource
if (fragmentResource != null) {
ContentFragment fragment = fragmentResource.adaptTo(ContentFragment.class);
 Iterator<ContentElement> elements = fragment.getElements();
while (elements.hasNext()){
ContentElement element = elements.next();
} }

https://aemdeveloper.wordpress.com/2017/08/22/create-access-the-content-fragment-programmatically/

 

Avatar

Community Advisor

Hi @ramaem12 ,

                           Yes, Can you please try on Vanilla instance  and if issue still persist then raise issue to the concerned team.

 

Regards,

Sanjay

Avatar

Community Advisor

Hi,

When you are creating the content fragment could you please check the logs and let us know whats coming there.

Avatar

Community Advisor

The content is stored under data node in latest AEM versions(not sure from which version), refer to the below image. The rendition folder is empty but the variations and the content is stored under data node

 

Repoinit.png

 

 

I was using specific logic to handle this - https://github.com/adobe/aem-core-wcm-components/blob/master/bundles/core/src/main/java/com/adobe/cq... (Just for your info) but as @Kishore_Kumar_  mentioned use the Content Fragment API to fetch the content.

Regards

Albin I

www.albinsblog.com

Avatar

Level 1

As @Albin_Issac mentioned, Latest version of AEM ( Ex: 6.5.13/14) CF data will be stored under cf/jcr:content/data/master node and variations are under cf/jcr:content/data/cf1(variations)

 

To get CF propeties: 

OOTB Content Fragment API will help to get all properties of CF which store under master node

//Get the resource of content fragment as below.
Resource fragmentResource = resourceResolver.getResource(“/content/dam/fragments/my-test-fragment”);

//Adapt it to a fragment resource
if (fragmentResource != null) {
ContentFragment fragment = fragmentResource.adaptTo(ContentFragment.class);
 Iterator<ContentElement> elements = fragment.getElements();
while (elements.hasNext()){
ContentElement element = elements.next();
} }

 

To get Image renditions:
- Observed that latest version of AEM CF renditions are not storing.
- For testing purpose, added some image renditions manually in CF reditions folder. if we want to get those renditions  by using CF API. have to loop rever (need to read parent from the child then loop the condition to get renditions node).

Note : recursiveness and it will not be generic approach.