How to extract assets/image for a specified page | Community
Skip to main content
June 30, 2023
Solved

How to extract assets/image for a specified page

  • June 30, 2023
  • 3 replies
  • 1022 views

Hi All,

I want to extract all the assets for a specified page.

I'm trying to explore ACS Common report.

 

I have added "Report Builder Config" component and added below query.

SELECT * FROM [nt:unstructured] AS s WHERE ISDESCENDANTNODE([{{path}}]) AND CONTAINS(s.*, '/content/dam/MyWorkSpace')

 

Then I have added "Report Basic Parameter" where I have a textfiled which takes user inputs. i.e. page path.

 

In the result, I have added "Report Text Column" and I'm configuring the 'Heading' & 'property'. ex Heading is "Hero Image" & property is "landingHeroImage".

 

I have two images on page one is 'Hero Image' & other is 'Gallery Image' then I'm again adding "Report Text Column" for Gallery Image.

 

the output result of this is I have two different columns in results.

But instead of two column can I get these all assets result in single column.

 

This is my current result,

Sr.no       Hero Image                                                Gallery Image

1             ../../TestHeroImage.png                              ../../GalleryImage.png

 

 

I want to try like this

Sr.no         Component                           Image Path                                               

1                Hero Image                          ../../TestHeroImage.png 

2.               Gallery Image                       ../../GalleryImage.png          

 

is it possible?                 

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 AsifChowdhury

Hi @charug 

You can get all the assets in a certain path by using a query builder. Then for all the assets you can find their references using ReferenceSearch API in this manner,

Collection<ReferenceSearch.Info> resultSet = new ReferenceSearch().search(resourceResolver, path).values();

 

3 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 30, 2023

I think an easy option is to use AssetSearchReference API, this will return a list of all the assets associated with a page, 

Here you have a full code sample of how to use it: 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 . By this mean, you will have control over how you want to display the results. 

Esteban Bustamante
Tanika02
Level 7
June 30, 2023

Hello @charug - 

 

Have you tried below approach ? 

 

To display all assets in a single column with their corresponding component names. Here's how you can try doing it:

 

1. Remove the separate "Report Text Column" for the "Gallery Image" and keep only the "Report Text Column" for the "Hero Image" in the result configuration.

 

2. Add a new "Report Text Column" for the component name. Set the "Heading" as "Component" and configure the "property" to the property that represents the component name in your page structure.

 

E.g., if the component name is stored in a property called "componentName", you can set the property value as "componentName".

 

3. In the "Component" column configuration, click on the "Format" tab.

 

4. Check the "Render HTML" option.

 

5. In the "Format" field, enter the following HTML code:

<strong>${componentName}</strong><br>${landingHeroImage}

 

6. Save the configuration and run the report.

 

CharuGAuthor
July 3, 2023

Hello @tanika02 ,

 

If I add 'Report Text Column' and go to configuration, I don't see "Format" tab. 

Can you please let me know how to find the "Format" tab? 

 

I have added screenshot for your reference. 

Thank you.

 

AsifChowdhury
Community Advisor
AsifChowdhuryCommunity AdvisorAccepted solution
Community Advisor
July 13, 2023

Hi @charug 

You can get all the assets in a certain path by using a query builder. Then for all the assets you can find their references using ReferenceSearch API in this manner,

Collection<ReferenceSearch.Info> resultSet = new ReferenceSearch().search(resourceResolver, path).values();