Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set background image of a div whose value is coming from a dialog(image url) in sightly component AEM?

Tags:

html

aem

I am working on a sightly component using AEM 6.1. I have a dialog from where I am getting an image url and I want to set that image as background of a div.

What I am doing is:

<div class="hero" style= "background-image:url('/content/dam/home/hero.jpg');" >

So, /content/dam/home/hero.jpg value is coming as dialog property

I am trying as..

<div class="hero" style= "background-image:url('${properties.bgimage}');" >

Its not working. How can I set the background image from the dialog property?

like image 772
Ashwini Avatar asked Oct 30 '25 03:10

Ashwini


1 Answers

Sightly doesn't detect the context of expressions within style and scripts automatically. We need to provide it explicity.

<div class="hero" style="background-image:url('${properties.bgimage @ context='styleString'}');" >

More about Display Context here.

like image 180
rakhi4110 Avatar answered Oct 31 '25 17:10

rakhi4110



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!