Can i specify an image style in my custom module I search everywhere in the web but i dont find any solution.

I make an entity query for get some nodes. I pass the nodes to my template. In there nodes, i have an image field. So my questions is, can i specify an image style in this case ?

Controllers.php

$query = $this-&gt;entity_query-&gt;get('node');
$query-&gt;condition('type', 'foo');
$nids = $query-&gt;execute();
$foos = $this-&gt;entity_manager-&gt;getStorage('node')-&gt;loadMultiple($nids);
return array(
        '#theme' =&gt; 'foo',
        '#foos' =&gt; $foos
    );


template.html.twig

{% for foo in foos %}
    &lt;img src='{{ file_url(foo.field_picture.entity.uri.value) }}'&gt;
{% endfor %}
There are several options:


Use a view
Use Twig Tweak with a display mode, where you configure the image style
Use this code How to find image style URL from within twig template?


If you don't need more than what is in your question, I would start with 1, because don't reinvent code for things that are in core.