Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

image-formatter.html.twig

Same filename in this branch
  1. 11.1.x core/themes/stable9/templates/field/image-formatter.html.twig
  2. 11.1.x core/themes/starterkit_theme/templates/field/image-formatter.html.twig

Default theme implementation 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()

2 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.
MediaThumbnailFormatter::viewElements in core/modules/media/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php
Builds a renderable array for a field value.

File

core/modules/image/templates/image-formatter.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation 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. * @ingroup themeable
  14. */
  15. #}
  16. {% if url %}
  17. {{ link(image, url) }}
  18. {% else %}
  19. {{ image }}
  20. {% endif %}

Related topics

Theme system overview
Functions and templates for the user interface that themes can override.
RSS feed
Powered by Drupal