Rendering an image field in page.html.twig with a custom image style I'm trying to set up a slideshow that's unique to each page. The code for this needs to be in page.html.twig. I've got the slideshow mostly working, but I can only call the full image URL, not a custom image style of a specific size. How can I modify this code to call a specific image size?

{% for key, item in node.field_slides %}
{% if node.field_slides[key].entity %}
&lt;figure class="swiper-slide"&gt;
    &lt;img class="swiper-image" src="{{ file_url(node.field_slides[key].entity.uri.value) }}" alt="{{ node.field_slides[key].alt  }}" /&gt;

    {% if node.field_slides[key].title %}
    &lt;figcaption class="swiper-caption"&gt;
        &lt;div class="swiper-user-content user-content"&gt;
            {{ node.field_slides[key].title|striptags("&lt;a&gt;,&lt;h1&gt;,&lt;h2&gt;,&lt;h3&gt;,&lt;h4&gt;,&lt;h5&gt;,&lt;h6&gt;,&lt;ol&gt;,&lt;p&gt;,&lt;table&gt;,&lt;ul&gt;")|raw }}
        &lt;/div&gt;&lt;!--/.swiper-user-content.user-content--&gt;
    &lt;/figcaption&gt;&lt;!--/.swiper-caption--&gt;
    {% endif %}
&lt;/figure&gt;&lt;!--/.swiper-slide--&gt;
{% endif %}
{% endfor %}


The bit where I'm calling the URL is:

{{ file_url(node.field_slides[key].entity.uri.value) }}


I've tried doing {{ dump(node.field_slides[key]) }} to see if there was any data I could use, but every time I do that, I just get 500 error.

Any help would be greatly appreciated; I'm very new to Drupal, coming from WordPress. I think this is the last major hurdle before I can finish up this theme for my client.
Replace the image tag

&lt;img class="swiper-image" src="{{ file_url(node.field_slides[key].entity.uri.value) }}" alt="{{ node.field_slides[key].alt  }}" /&gt;


with a render array for the image style:

{% set imagestyle = {
  '#theme':      'image_style',
  '#style_name': 'medium',
  '#uri':        node.field_slides[key].entity.uri.value,
  '#alt':        node.field_slides[key].alt,
  '#attributes': { class: 'swiper-image' },
} %}

{{ imagestyle }}


Edit:

There is a new filter in the module Twig Tweak. Now you can generate the image style url in twig directly from an uri or url:

{{ node.field_slides[key].entity.uri.value | image_style('thumbnail') }}