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 ?


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


{% for foo in foos %}
    <img src='{{ file_url(foo.field_picture.entity.uri.value) }}'>
{% endfor %}

1 Answer 1


There are several options:

  1. Use a view
  2. Use Twig Tweak with a display mode, where you configure the image style
  3. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.