Skip to main content

Accessing image field attributes twig in Drupal 8

Member for

2 years 2 months
Submitted by admin on

To access image field attributes in Drupal 8 you can call the kint() function that is in the devel module. You can access all sorts of information, one that can be really useful is the title tag.

 // See inside image array
 {{kint(image)}}

 // See title string
 {{kint(image['#attributes'].title)}}

  // Print string inside template
  {{image['#attributes'].title}}