Skip to main content
Level 2
August 12, 2025
Répondu

Load Images in Without Breaking Existing Fallback Logic

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?

Ce sujet a été fermé aux réponses.
Meilleure réponse par SantoshSai

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.

1 commentaire

SantoshSai
Community Advisor
SantoshSaiCommunity AdvisorRéponse
Community Advisor
August 12, 2025

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