I am trying to render the teaser image in my search block using twig. For my views page for rending the articles i am using this:

  <div class="img-container" itemscope="" itemtype="http://schema.org/imageObject" data-internal-url="{{ url }}">
    {% block teaser_img_container %}
        {{ content.field_teaser_media }}
    {% endblock %}

And it works very nice but on search block it does not display the image, so I am trying other options like

<div class="img-container" itemscope="" itemtype="http://schema.org/imageObject" data-internal-url="{{ url }}">

   {% block teaser_img_container %}

<img src="{{ file_url(node.field_teaser_media.entity.uri.value) }}" >
 {% endblock %}


Which should solve my problem, but i still don't see the image i am getting no errors, if i go in my page source the link to image appears but when i inspect the code from I get

<img src="/">

The link works, but it does not display my image. Any ideas for fix?

  • I see in your code you have node.field_teaser_media.entity.uri.value but which node? You could have 200 nodes on your site, so which one? Is there a specific one?
    – No Sssweat
    Commented Sep 12, 2016 at 8:11

2 Answers 2


You could use the URL Formatter Module

Then go to Manage Display and for your image field and select URL Formatter as your formatter.

then use: <img src="{{ content.field_teaser_media[0] }}">

enter image description here

  • I installed the module but can't seem to find url formatter i only have : Entity ID, Rendered Entity, Label, Thumbnail, Data Internal Url. I have tried all of them but to no success Commented Sep 10, 2016 at 14:42
  • @DraguAlexandru sorry it's in Manage Display not Manage Fields, my memory was off. Provided pic to clear things up.
    – No Sssweat
    Commented Sep 10, 2016 at 19:32
  • Thank you for your quick response i don't find it because i am not using image field, i am using Entity reference, the type of reference is media and from there i am getting my images. Commented Sep 11, 2016 at 13:11
  • Hi, I get for first code <a href="s14.postimg.org/kayrb9e1t/search_example.jpg">Link Here</a> I get for second try<a href="s11.postimg.org/i5z4v30oz/search_example2.jpg">Link Here</a> Commented Sep 13, 2016 at 11:32

The problem was in my Manage Display i forgot to put my Teaser Default (Display from where i take my default settings for other teaser displays) to the format Rendered Entity.

Thank you for your help.

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.