Skip to main content
2 of 3
added 163 characters in body
ya.teck
  • 5.7k
  • 3
  • 35
  • 40

This is the way if you want to get the image URL with the associated image style for any image field in a twig template:

First install the Twig Tweak module

Then set the image URI as a variable. With the URI, you can use a twig tweaks pattern to get the path with whatever image style you want. See below:

{% set image_uri = content.field_feature_row_image['#items'].entity.uri.value %}

<img src="{{ image_uri|image_style('image1200x1103') }}"/>

Twig Tweak v2.4+ offers file_url filter to extract file URL from an entity.

<img src="{{ node.field_image|file_url|image_style('image1200x1103') }}"/>
Robb Davis
  • 419
  • 4
  • 7