Skip to content

Instantly share code, notes, and snippets.

@claudiainbytes
Last active December 6, 2018 22:54
Show Gist options
  • Save claudiainbytes/d9c9d84fa16d4afcf488086711082e98 to your computer and use it in GitHub Desktop.
Save claudiainbytes/d9c9d84fa16d4afcf488086711082e98 to your computer and use it in GitHub Desktop.
Drupal 8 Image Style using Twig
# Example 1.
<div class="col-md-8 blog--caja-right">
{% set imageblog = {
'#theme': 'image_style',
'#style_name': 'despliegue_blog',
'#uri': node.field_image.entity.uri.value,
'#attributes': { class: 'img-responsive' },
} %}
{{ imageblog }}
</div>
# Example 2.
#Install the Twig Tweak Module https://www.drupal.org/project/twig_tweak
#And this module Twig Field https://www.drupal.org/project/twig_field_value
<img src="{{ node.field_image.entity.uri.value | image_style('despliegue_1366x768_px') }}" alt="{{ node.field_image.alt }}"/>
# Example 3
<img class="img-responsive" src="{{ content.field_imagen.0['#item'].entity.uri.value | image_style('minuto_a_minuto_560x315_px') }}" alt="{{ content.field_imagen['#items'].alt }}"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment