Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
Nível 1
Nível 2
Faça login na Comunidade
Faça logon para exibir todas as medalhas
Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
I have a backend Sling model which fetches the asset path and then fetches the description from the asset and I display the same in HTL using helper class. It is working for all image types but not for svg images. What maybe the issue here?
Solucionado! Ir para a Solução.
Visualizações
respostas
Total de curtidas
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;
}
}
If that's your SlingModel you should able to debug and check what is the issue, i don't think it is related to the assetType, but maybe the asset does not have the property you are searching for?
Just in case I am attaching how you can debug your sling model: https://aemgeeks.com/aem-debugging/how-to-start-aem-in-debug-mode/
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;
}
}
Yes, I do have the dc:description associated with the image. I'll modify my code as per your snippet and check if it works.
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas