I have a custom block type that only has one field: an entity reference to my news content type. I am trying to display two specific fields from the news content type but can't figure it out.

This entity reference field has a machine name of field_featured_news

I have created a file with the filename block--block-content-testnews.html.twig

In this file, I can use {{ content }} and it will render the full entity (based on the settings in Manage Display.

However, I can't access the image field that is within the news content type. The field's machine name is called field_featured_news_image.

I have tried adding the following to no avail:

{{ content.field_featured_news_image }} {{ content.field_featured_news_image.0 }} {{ content.field_featured_news_image.entity.uri.value }}

and many others.

Only {{ content }} will display anything but it's the entire news node.

  • In the code, replace the word "node" with "block" from the accepted answer.
    – No Sssweat
    Apr 16 '20 at 4:30
  • {{ block.field_featured_news.0.entity.field_featured_news_image.0.value }}
    – No Sssweat
    Apr 16 '20 at 4:37
  • Thanks for the attempt but that didn't work. Nothing loaded. Apr 18 '20 at 2:35
  • You flushed the cache?
    – No Sssweat
    Apr 18 '20 at 3:09

Browse other questions tagged or ask your own question.