Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Image Path URL Encoding in Sightly

Avatar

Level 2

There is a container component developed having a image field to author a Background Image with sling:resourceType --> cq/gui/components/authoring/dialog/fileupload. When images with space in their name are drag and drop into the image field it is stored along with the spaces in the node. As the image properties are read in Sightly using properties.imagepath, the spaces in the image path is creating issue to display the image as background image. Is there a way to encode the URL of the image path in Sightly or to remove or replace the image path spaces in sightly (HTL). The image path stored in page is -- /content/dam/bhn/Flowers FTD Image.png .

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Sayali1 : 

 

Using below Javascript function you can get the path for the image 

 

"encodeURI('/content/dam/bhn/Flowers%20FTD%20Image.png'); 

'/content/dam/bhn/Flowers%20FTD%20Image.png'

 

You can invoke this Javascript functionn from your sightly code.

 

Thanks 

Siva

Thanks,
Siva

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@Sayali1 : 

 

Using below Javascript function you can get the path for the image 

 

"encodeURI('/content/dam/bhn/Flowers%20FTD%20Image.png'); 

'/content/dam/bhn/Flowers%20FTD%20Image.png'

 

You can invoke this Javascript functionn from your sightly code.

 

Thanks 

Siva

Thanks,
Siva