Created
December 13, 2019 17:18
-
-
Save mecmartini/49b57dde0ba87503f03153493597fb22 to your computer and use it in GitHub Desktop.
How to render responsive image style on Twig in Drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set imagePath = 'public://images/default.jpg' %} | |
{% set responsiveimagestyle = { | |
'#theme': 'responsive_image', | |
'#responsive_image_style_id': 'my_responsive_image_style_id', | |
'#uri': imagePath, | |
'#alt': 'my alt text', | |
'#attributes': { class: 'img-responsive' }, | |
} %} | |
{{ responsiveimagestyle }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice little snippet !
Thanks for sharing, came in handy today.