Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aastrong/42a27bf394499a0f2a107cd435c87871 to your computer and use it in GitHub Desktop.
Save aastrong/42a27bf394499a0f2a107cd435c87871 to your computer and use it in GitHub Desktop.
How to render responsive image style on Twig in Drupal
{% 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