Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

Load Images in Without Breaking Existing Fallback Logic

Avatar

Level 2

Hi All,

I’m working on a customization where the setRollUpImage method in our component is responsible for setting an image path. Currently, it works for most cases, but in some situations rollUpImage is null because the primary source doesn’t return a value.

I want to add a fallback so that if the current logic doesn’t return a valid image, it should use delegate.getSrc() instead - without affecting the existing functionality.

What’s the best way to modify the method so it still respects the current logic but adds this fallback?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @EthanRo5,

Have you tried this by adding a simple null or empty check after your existing logic in setRollUpImage? I appreciate if you provide us detailed code/logs to understand and resolve your issue please.  Try this below reference example:

public void setRollUpImage(String rollUpImage) {
    // Existing logic for setting the image
    this.rollUpImage = rollUpImageFromPrimarySource();

    // Fallback logic
    if (StringUtils.isBlank(this.rollUpImage)) {
        this.rollUpImage = delegate.getSrc();
    }
}

This ensures that the fallback is only used if the primary assignment didn’t produce a valid image path.


Santosh Sai

AEM BlogsLinkedIn


View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @EthanRo5,

Have you tried this by adding a simple null or empty check after your existing logic in setRollUpImage? I appreciate if you provide us detailed code/logs to understand and resolve your issue please.  Try this below reference example:

public void setRollUpImage(String rollUpImage) {
    // Existing logic for setting the image
    this.rollUpImage = rollUpImageFromPrimarySource();

    // Fallback logic
    if (StringUtils.isBlank(this.rollUpImage)) {
        this.rollUpImage = delegate.getSrc();
    }
}

This ensures that the fallback is only used if the primary assignment didn’t produce a valid image path.


Santosh Sai

AEM BlogsLinkedIn