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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Default Image for Image Component

Avatar

Level 2

I am using OOB image component , but I have a requirement where I need to set up a default image for my image component. In some templates this component will be included directly in the templates, there I need to show this default image. Once image is selected by the author, that image will be displayed. Please provide me the code to acheive this requirement.

1 Accepted Solution

Avatar

Correct answer by
Level 9
When you get the properties of image, provide an alternative path in case there is no image.String image = properties.get("your_image_path", "/some/path/mysitelogo.jpg"); %><div class="image"><img src="<%= image%>" alt="Alternate text" ></div><%

This will return the default value to your image (after you correct the path). Since the ValueMap will automatically return the default value if the retrieved value is null, you no longer have to do the null check.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 9
When you get the properties of image, provide an alternative path in case there is no image.String image = properties.get("your_image_path", "/some/path/mysitelogo.jpg"); %><div class="image"><img src="<%= image%>" alt="Alternate text" ></div><%

This will return the default value to your image (after you correct the path). Since the ValueMap will automatically return the default value if the retrieved value is null, you no longer have to do the null check.

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now