Forked from mecmartini/render-reponsive-image-style-twig-drupal.html-twig
Created
January 16, 2023 14:33
-
-
Save aastrong/42a27bf394499a0f2a107cd435c87871 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