Display a Media Entity Image from other (referencing) node in a Twig template Seems that all found in the Internet does not work for my case. :/
In general, I need to display an Image and a Project, referenced by the node that has a reference field to my node.

I have:


a node of CT Idea (here I want to display my content)
a node of CT Example, which has:

1) a ref field to Idea
2) a ref field to a Media, Image
3) a ref field to a CT Project


I want to display Examples on an Idea page, each Example displays:
Description, Image, Project link

I've managed to display the Description, but can not display Image and Project.

Here is the code

in the *.theme file:

function showcase_lite_preprocess_node__idea(&amp;$variables) {
  $current_node = $variables['node'];
  $current_node_id = $current_node-&gt;id();

  $query = \Drupal::entityQuery('node');
  $query-&gt;condition('type', 'example');
  $query-&gt;condition('status', 1);
  $query-&gt;condition('field_example_ideas', $current_node_id);
  $nids = $query-&gt;execute();
  $relatednodes = Node::loadMultiple($nids);

  if (!empty($relatednodes)) {
    foreach ($relatednodes as $related_node) {
      $related_node_image = $related_node-&gt;field_example_image-&gt;value;
      $related_node_description = $related_node-&gt;field_example_description-&gt;value;
      $related_node_project = $related_node-&gt;field_example_project-&gt;value;

      $variables['related_node_image'] = $related_node_image;
      $variables['related_node_description'] = $related_node_description;
      $variables['related_node_project'] = $related_node_project;
    }
  }
}


In the node--idea.html.twig file:

{% block content %}
    {{ content }}
    {{ related_node_description }}
    {{ related_node_image }}
    {{ related_node_project }}
{% endblock %}


This displays only the Idea content and the Example Description.

It seems to me that the problem is that the format of $related_node_image and $related_node_project does not correspond to what Twig is expecting. But I can not check what is inside the variable, because Kint gives an error of memory limit.

Drupal version: 8.5.3.
To get a renderable output for Twig use EntityViewBuilder::viewMultiple()

    $variables['related_nodes'] = \Drupal::entityTypeManager()
      -&gt;getViewBuilder('node')
      -&gt;viewMultiple($relatednodes, $view_mode, $current_node-&gt;language()-&gt;getId());


and configure the three fields in the view mode you've specified here.