Add an imagestyle to a template twig Im using the Aegan theme, and it uses it's own slideshow. Now I'd like it to use a specific image style, that formats the images according to my presets.

The code in the page.html.twig looks like this

{# Include a slider. #}
  {% if slider %}
    &lt;div class="flexslider"&gt;
      &lt;ul class="slides"&gt;
        {% for slide in slider %}
          &lt;li&gt;
            &lt;a href="{{ slide.url }}"&gt;&lt;img src="{{ slide.src }}" alt="{{ slide.name }}"&gt;&lt;/a&gt;
            {% if slide.description %}
              &lt;p class="flex-caption"&gt;{{ slide.description | raw }}&lt;/p&gt;
            {% endif %}
          &lt;/li&gt;
        {% endfor %}
  &lt;/ul&gt;
&lt;/div&gt;{% endif %}


The style is called aegan_slide (don't really know where I can find it. But how do I apply my custom style to this code?
If you don't use sub themes of Aegan, you need edit file aegan.theme 

Add more use class at top:

use Drupal\image\Entity\ImageStyle;


Replace code line 53->73 

if ($slideshow_path &amp;&amp; $show_slideshow) {
    $vars['slider'] = array();
    for ($i = 1; $i &lt;= theme_get_setting('slideshow_count', 'aegan'); $i++) {
      $fid = theme_get_setting("slide_image_{$i}", "aegan");
      if (!empty($fid)) {
        $file = \Drupal\file\Entity\File::load($fid[0]);
        $uri = $file-&gt;getFileUri();
        $image_path = file_create_url($uri);
      }
      else {
        $image_path = THEME_PATH . "/images/slide-{$i}.jpg";
      }
      $vars['slider'][] = array(
        'name' =&gt; !empty($fid) ? $file-&gt;getFilename() : "slider-{$i}",
        'url' =&gt; theme_get_setting("slide_url_{$i}", "aegan"),
        'src' =&gt; $image_path,
        'description' =&gt; theme_get_setting("slide_description_{$i}", "aegan"),
      );
    }
  }


with 

if ($slideshow_path &amp;&amp; $show_slideshow) {
    $vars['slider'] = array();
    //replace large with image style you want
    $image_style = 'large';
    $image = ImageStyle::load($image_style);
    for ($i = 1; $i &lt;= theme_get_setting('slideshow_count', 'aegan'); $i++) {
      $fid = theme_get_setting("slide_image_{$i}", "aegan");
      if (!empty($fid)) {
        $file = \Drupal\file\Entity\File::load($fid[0]);
        $uri = $file-&gt;getFileUri();
        $image_path = $image-&gt;buildUrl($uri);
      }
      else {
        $image_path = THEME_PATH . "/images/slide-{$i}.jpg";
      }
      $vars['slider'][] = array(
        'name' =&gt; !empty($fid) ? $file-&gt;getFilename() : "slider-{$i}",
        'url' =&gt; theme_get_setting("slide_url_{$i}", "aegan"),
        'src' =&gt; $image_path,
        'description' =&gt; theme_get_setting("slide_description_{$i}", "aegan"),
      );
    }
  }