1

I have a taxonomy term with the name 'Colors' and it has 1 image field called field_color_image. In my project I have a node type with a field type of Taxonomy term that refer to Colors. My aim is that I want to show the image in the Colors taxonomy to a node. I already used kint and it didn't really help. How do I achieve this? Thank you beforehand.

1 Answer 1

5

To get the url of your term reference image inside the node twig try:

node.field_color_term.0.entity.field_color_image.entity.uri.0.value 

Change field_color_term by your field name.

There is another way by configuring the display of your content type and your term like the following:

  1. Content type display should be like enter image description here
  2. Taxonomy term display should be like enter image description here

After this configuration you can render your field type of Taxonomy term, it will show the image:

{{ content.field_YOURFIELDNAME }}
2
  • node.field_color_term.0.entity.field_color_image.entity.uri.0.value really saved the day! Thank you! Commented Apr 27, 2020 at 1:50
  • Welcome, i'm glad that helped !
    – berramou
    Commented Apr 27, 2020 at 8:40

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.