Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Fetching thumbnail image using JCR API

Avatar

Level 2

Hi All,

Using JCR API i want to fetch the value of thumbnail image of a Asset. 

Purpose.

I am trying to display the thumbnail image of a Book in the main page and on click of it i will display the complete details including the main image  of the Book.

 

I tried to fetch the data from under imagenode/rendition folder.

 

Thanks in Advance.

1 Accepted Solution

Avatar

Correct answer by
Level 6

Try:

Resource resource = resourceResolver.getResource("/content/dam/Rental/prod1.gif");

Notice the / in the beginning of the resource path.

/Ove

View solution in original post

3 Replies

Avatar

Level 2

Tried in the following way

       ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);
        Resource resource = resourceResolver.getResource("content/dam/Rental/prod1.gif");
        Asset asset = resource.adaptTo(Asset.class);
        Rendition thumb = asset.getRendition("cq5dam.thumbnail.48.48.png");

 

getting a null pointer exception in line 3 (Asset asset = resource.adaptTo(Asset.class);)

Image  is available in the Asset able to access the metadata using JCR API.

Avatar

Correct answer by
Level 6

Try:

Resource resource = resourceResolver.getResource("/content/dam/Rental/prod1.gif");

Notice the / in the beginning of the resource path.

/Ove