Find all referenced images in DAM from activated/published pages | Community
Skip to main content
Level 2
August 16, 2023
Solved

Find all referenced images in DAM from activated/published pages

  • August 16, 2023
  • 5 replies
  • 1965 views

@1905403 ,

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

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mahedi_Sabuj

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/src/main/java/com/adobe/cq/tutorials/assets/impl/ReferencedAssetsServlet.java 

5 replies

Mahedi_Sabuj
Community Advisor
Mahedi_SabujCommunity AdvisorAccepted solution
Community Advisor
August 16, 2023

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/src/main/java/com/adobe/cq/tutorials/assets/impl/ReferencedAssetsServlet.java 

Mahedi Sabuj
sherinregi-1
Community Advisor
Community Advisor
August 16, 2023

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-all-images-used-in-content-pages/m-p/415764

 

 

 

 

 

Ritesh_Mittal
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
August 16, 2023

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

Level 2
August 16, 2023

Thanks @ritesh_mittal @sherinregi-1 @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. 

Mahedi_Sabuj
Community Advisor
Community Advisor
August 16, 2023

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.

Mahedi Sabuj
Level 2
August 16, 2023

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.

Harwinder-singh
Community Advisor
Community Advisor
August 17, 2023

@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/granite/references/ReferenceAggregator.html

 

Hope this helps