Add target blank to an image link How do I add target='blank' to a href in a Drupal 8 custom module? Below I have the image being wrapped by the uri. I don't know how to add target='blank'

  $element[$delta] = array(
        '#theme' =&gt; 'image_formatter',
        '#item' =&gt; $item,
        '#image_style' =&gt; '',
        '#url' =&gt; $uri,
      );
I think (not checked) that you need to add "target" => "_blank"  ((note underscore)) to the #attributes array. However, that attribute must appear on an  element that encloses the , not the  itself, and I'm not sure if adding it to the structure in your question would do that... have a go.

If it doesn't work, simplest option is to override the twig template in question and then extend attributes with "attributes.setAttribute('target', '_blank')" in the appropriate place.

Determine the right file name to override the twig template with by using twig debug (look in the sites/default/local.services.yml for the setting to change).
, and then view-source of the page (noting there are now lots and lots of html comments), find the existing image html and look before it to see the table of possible templates. There is lots more about this in the official Drupal documentation on twig.