image-formatter.html.twig

Same filename in this branch
  1. 9 core/themes/stable/templates/field/image-formatter.html.twig
  2. 9 core/themes/starterkit_theme/templates/field/image-formatter.html.twig
  3. 9 core/themes/classy/templates/field/image-formatter.html.twig
  4. 9 core/modules/image/templates/image-formatter.html.twig
Same filename and directory in other branches
  1. 8.9.x core/themes/stable/templates/field/image-formatter.html.twig
  2. 8.9.x core/themes/classy/templates/field/image-formatter.html.twig
  3. 8.9.x core/modules/image/templates/image-formatter.html.twig
  4. 10 core/themes/stable9/templates/field/image-formatter.html.twig
  5. 10 core/themes/starterkit_theme/templates/field/image-formatter.html.twig
  6. 10 core/modules/image/templates/image-formatter.html.twig
  7. 11.x core/themes/stable9/templates/field/image-formatter.html.twig
  8. 11.x core/themes/starterkit_theme/templates/field/image-formatter.html.twig
  9. 11.x core/modules/image/templates/image-formatter.html.twig

Theme override to display a formatted image field.

Available variables:

  • image: A collection of image data.
  • image_style: An optional image style.
  • url: An optional URL the image can be linked to.

See also

template_preprocess_image_formatter()

3 theme calls to image-formatter.html.twig
ImageFormatter::viewElements in core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
Builds a renderable array for a field value.
ImageThemeFunctionTest::testImageFormatterTheme in core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php
Tests usage of the image field formatters.
MediaThumbnailFormatter::viewElements in core/modules/media/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php
Builds a renderable array for a field value.

File

core/themes/stable9/templates/field/image-formatter.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override to display a formatted image field.
  5. *
  6. * Available variables:
  7. * - image: A collection of image data.
  8. * - image_style: An optional image style.
  9. * - url: An optional URL the image can be linked to.
  10. *
  11. * @see template_preprocess_image_formatter()
  12. */
  13. #}
  14. {% if url %}
  15. {{ link(image, url) }}
  16. {% else %}
  17. {{ image }}
  18. {% endif %}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.