Expand my Community achievements bar.

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

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

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

Community Advisor

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