dynamic media - aem | Community
Skip to main content
AEMLearner-1989
Level 4
January 29, 2021
Solved

dynamic media - aem

  • January 29, 2021
  • 1 reply
  • 1310 views

Hi Team,

 

I am able to get the responsive image on my custom component by using responsive . It working for img tag.

 

https://experienceleague.adobe.com/docs/dynamic-media-developer-resources/image-serving-api/image-serving-api/responsive-static-image-library/t-using-responsive-static-image-library.html?lang=en#image-serving-api

 

But its not working for background-image:url div class. any suggestions?

<div class="hero__image" style="background-image:url('${dynamicmedia.fileReference @ context='styleString'}')"></div>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by khamat_bn

Hi @aemlearner-1989 

 

as you are referring Dynamic Media Image so please try 'uri' instead of 'styleString' in context. 

 

<div class="hero__image" style="background-image:url('${dynamicmedia.fileReference @ context='uri'}')"></div>

 

 

1 reply

khamat_bn
khamat_bnAccepted solution
Level 4
January 30, 2021

Hi @aemlearner-1989 

 

as you are referring Dynamic Media Image so please try 'uri' instead of 'styleString' in context. 

 

<div class="hero__image" style="background-image:url('${dynamicmedia.fileReference @ context='uri'}')"></div>

 

 

AEMLearner-1989
Level 4
February 3, 2021

How to handle responsive image library for background-image:url

 

<div class="hero_image" style="background-image:url('${dynamic.fileReference @ context='uri'}')"></div>

 

Its working as expected for <img> tag.