Expand my Community achievements bar.

SOLVED

Find all referenced images in DAM from activated/published pages

Avatar

Level 2

@All ,

We have a requirement where we need to find all the referenced assets from published/live pages on our PROD server. we have any analytics available on this or any script or code that can fetch this information

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @nithinthomas 

AEM have internal service (AssetReferenceSearch) to get reference images.

AssetReferenceSearch search = new AssetReferenceSearch(
  jcrNode, DAM_ROOT, request.getResourceResolver()); 

Map<String,Asset> result = search.search();
for (String key: result.keySet()) {
  Asset asset = result.get(key);
  // asset properties
  Sring path = asset.getPath();
  String mimeType = asset.getMimeType();
  ...							
}

Reference:
https://github.com/Adobe-Marketing-Cloud/aem-samples/blob/master/tutorial-referenced-assets/bundle/s... 

View solution in original post

9 Replies

Avatar

Correct answer by
Community Advisor

Hi @nithinthomas 

AEM have internal service (AssetReferenceSearch) to get reference images.

AssetReferenceSearch search = new AssetReferenceSearch(
  jcrNode, DAM_ROOT, request.getResourceResolver()); 

Map<String,Asset> result = search.search();
for (String key: result.keySet()) {
  Asset asset = result.get(key);
  // asset properties
  Sring path = asset.getPath();
  String mimeType = asset.getMimeType();
  ...							
}

Reference:
https://github.com/Adobe-Marketing-Cloud/aem-samples/blob/master/tutorial-referenced-assets/bundle/s... 

Avatar

Community Advisor

Hi @nithinthomas 

 

There are multiple ways to achieve your requirement. One of the ways is through the referenced asset servlet also you can refer to the below link where it talks about custom java implementation and also on the query builder approach where you can further refine your filtering and get a targeted result.

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-find-the-list-of-al...

 

 

 

 

 

Avatar

Community Advisor

Hi @nithinthomas ,

 

One of the way would be to use ACS commons MCP tool "Renovator". You can use same 'source' and 'Target' folder and 'select 'Dry Run' checkbox. you can download the excel report and can filter the report with 'references' column as zero.

 

https://adobe-consulting-services.github.io/acs-aem-commons/features/mcp-tools/renovator/index.html

 

Hope it helps!

 

Thanks,

Ritesh Mittal

Avatar

Level 2

Thanks @Ritesh_Mittal @sherinregi @Mahedi_Sabuj  for the response. We want to do this activity on the PROD instance and we cannot do a deployment basically a java change as this point to time. Considering this what is the best next step to try in short time. 

Avatar

Community Advisor

Hi @nithinthomas, You can find the assets reference using reference.json API

http://localhost:4502/libs/wcm/core/content/reference.json?path=contentPath

You need to manually filter type: "asset" to get reference assets only.

Avatar

Community Advisor

Hi @nithinthomas ,

 

Do you have the ACS AEM Commons MCP installed in PROD instance, if yes, then its report generation process.

Avatar

Community Advisor

@nithinthomas  If you have groovy console enabled , then you can also try deriving groovy from the java snippets and try to get the asset list

Avatar

Level 2

You can filter search results based on the various options (predicates), such as, file type, file size, last modified date, status of asset, insights data, and Adobe Stock licensing. You can customize the Filters panel and add or remove search predicates using search facets.

Avatar

Community Advisor

@nithinthomas , Do you have Groovy console installed on your AEM instance?

If yes, you can create a simple groovy script and make use of the ReferenceAggregator API to find all asset references for a given content resource. 

 

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/index.html?com/adobe/...

 

Hope this helps