Weesperstraat 61-105
1018 VN Amsterdam
The Netherlands

How to get the 'image field url' from a referenced node in a Drupal Twig node template

06 Aug, 2026 Drupal

After quite some Google searching I found some answers that came close, but nothing that worked straight away. So to prevent you from puzzling and searching, here is how to get the image field url from a referenced node in a Twig node template

Use this code for example in node--blog--teaser.html.twig :

 

<img src="{{ file_url(node.field_REFERENCE.entity.field_IMAGE.entity.uri.value) }}" 
     alt="{{ node.field_REFERENCE.entity.field_IMAGE.entity.alt.value }}" />

Replace 'field_REFERENCE' with your node reference field system name, and replace 'field_IMAGE'  with the system name of your image field.

And by the way: more on Twig file naming conventions in Drupal here.

Drupal theming Planet Drupal
Written by Joris Snoek | Aug 06, 2026
Drupal project? Let's Talk

Please tell me all about your project!
Mail , or send a message:

Got some more time?

Related content

23 Oct 2026 Drupal

Legacy code, all cleaned up

**I had been postponing Drupal coding standards fixes in Drupal distro [OpenLucius](https://www.drupal.org/project/openlucius) for far too long. There were always more interesting things to do: fixing bugs, building new features, and improving existing functionality.** Fixing hundreds of PHPCS…

Read more →

16 Oct 2026 Drupal

There’s an incredible amount of things happening in the world of Drupal and AI. It’s very exciting, but almost impossible to keep up with. I’d been planning for a while to seriously dive into agentic coding. I feel a little late to the party, but at the same time, I get the impression that many…

Read more →

28 Sep 2026 Drupal

AI as a programming partner

A request from a product owner: their Drupal website has a content type called 'Event'. The editorial team wants to display a block on the homepage showing the next three events. ## The initial request and AI prompt > “Create a Drupal block that displays the next three events, sorted by start…

Read more →

21 Sep 2026 Drupal

With new features like: @-mentions, drag-and-drop images & general settings.

Last week we released a new version of OpenLucius: a lean and&nbsp;fast Drupal social collaboration distribution with features like: groups, social posts, messages, group chats, stories, file -and folder management, notebooks, categories, activity streams, notifications, @-mentions, comments and…

Read more →