Loading default image from a node field in page.html.twig I want to print the default image of a node field into the page.html.twig template file in Drupal 8. On doing my research the easiest approach I could find was

{% if node.field_image.entity %}
   &lt;img src="{{ file_url(node.field_image.entity.uri.value) }}"
        alt="{{ node.field_image.alt  }}"
        {% if node.field_image.title %}
        title="{{ node.field_image.title }}"
        {% endif %}
   /&gt;
{% endif %}

This works if I load an image in the field but not otherwise with the default image of the image field. I want to use the above code to print the default image that I pick for this image field. Currently the above method gives &lt;img src="http://example.com/" alt=""&gt; for the default image

How can I access the uri value of the default image in the src of the image tag above. Is there any other way to print the default image of a node in the page.htm.twig preferably from within the template layer as I don't have any experience with preprocess functions etc.? My objective is to have a static image which is the same throughout the content type.
Here's one approach, using a helper method. It assumes you have access to the loaded node entity ($entity), and would like to get either the set, or default image for a given image field. I've also left comments and links that explain why Drupal::service('entity.repository') is being used, and how I discovered the way in which the Image module loads the default image settings.

    /**
 * Get the set or default image uri for a file image field (if either
 * exist).
 * @param $entity
 * @param $fieldName
 * @return null|string
 */
function get_image_uri($entity, $fieldName) {
  $image_uri = NULL;
  if( $entity-&gt;hasField($fieldName) ) {
    try {
      $field = $entity-&gt;{$fieldName}; //Try loading from field values first.
      if ($field &amp;&amp; $field-&gt;target_id) {
        $file = File::load($field-&gt;target_id);
        if ($file) {
          $image_uri = $file-&gt;getFileUri();
        }
      }
    } catch (\Exception $e) {
      \Drupal::logger('get_image_uri')-&gt;notice($e-&gt;getMessage(), []);
    }

    // If a set value above wasn't found, try the default image.
    if (is_null($image_uri)) {
      try {
        $field = $entity-&gt;get($fieldName); // Loading from field definition
        if ($field) {
          // From the image module /core/modules/image/ImageFormatterBase.php
          // $default_image = $test-&gt;fieldDefinition-&gt;getFieldStorageDefinition()-&gt;getSetting('default_image');
          $default_image = $field-&gt;getSetting('default_image');
          if ($default_image &amp;&amp; $default_image['uuid']) {
            // $defaultImageFile = \Drupal::entityManager()-&gt;loadEntityByUuid('file', $default_image['uuid']));
            // See https://www.drupal.org/node/2549139  entityManager is deprecated.
            // Use entity.repository instead.
            $entityrepository = Drupal::service('entity.repository');
            $defaultImageFile = $entityrepository-&gt;loadEntityByUuid('file', $default_image['uuid']);
            if($defaultImageFile) {
              $image_uri = $defaultImageFile-&gt;getFileUri();
            }
          }
        }
      } catch (\Exception $e) {
        \Drupal::logger('get_image_uri')-&gt;notice($e-&gt;getMessage(), []);
      }
    }
  }

  return $image_uri;
}