Hello @arindam6600 -
First, validate that you do have the jcr:description/dc:description associated with the image.
In AEM, the description property for PNG images is typically stored directly under the image resource node, while for SVG images, the description property is often stored in a separate rendition node.
To address this, you can modify the Sling model a bit to handle the specific storage location of the description property for SVG images.
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class SvgImageModel {
private final Resource resource;
public SvgImageModel(Resource resource) {
this.resource = resource;
}
public String getDescription() {
ValueMap properties = resource.getValueMap();
String description = properties.get("jcr:description", String.class);
if (description == null && resource.getParent() != null) {
Resource parentResource = resource.getParent();
ValueMap parentProperties = parentResource.getValueMap();
description = parentProperties.get("jcr:description", String.class);
}
return description;
}
}