Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

How to extract assets/image for a specified page

Avatar

Level 1

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?                 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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();

 

View solution in original post

4 Replies

Avatar

Community Advisor

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/s... . By this mean, you will have control over how you want to display the results. 



Esteban Bustamante

Avatar

Community Advisor

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.

 

Avatar

Level 1

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.

 

Avatar

Correct answer by
Community Advisor

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();