Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to get & display image on the Page

Avatar

Level 5

Hello all, 

 

I am trying to create a custom image component for that I need to get and display the image on the AEM page. In what are the ways I can do this and how to do? I tried with valuemap but not getting the exact results. Can anyone help me?

1 Accepted Solution

Avatar

Correct answer by
Employee

As mentioned by Arun, Check image core component implementation [1], and follow the same approach.
On a high level, the code should look like this:

public class ImageModel {
    @ValueMapValue
    private String fileReference;

    public String getFileReference() {
        return fileReference;
    }
}

 

[1] https://github.com/adobe/aem-core-wcm-components/blob/main/content/src/content/jcr_root/apps/core/wc... 

View solution in original post

4 Replies

Avatar

Employee

The requirement is a bit unclear to me. Will your image component has a dialog to select an image or image component read an image from the page property?

Avatar

Level 5

yes , I have a dialog with image & text field . And I want to retrive them and display on page using sling model. 

 

Avatar

Correct answer by
Employee

As mentioned by Arun, Check image core component implementation [1], and follow the same approach.
On a high level, the code should look like this:

public class ImageModel {
    @ValueMapValue
    private String fileReference;

    public String getFileReference() {
        return fileReference;
    }
}

 

[1] https://github.com/adobe/aem-core-wcm-components/blob/main/content/src/content/jcr_root/apps/core/wc...