Media Helper
13 sites
Security covered
This module helps you customize how media entities, like images and videos, are displayed on your site. It allows you to control image styles, add custom classes, and specify HTML attributes directly in field formatters or Twig templates, with automatic cache handling.
This module serves two main purposes:
- Making it easier to customize the output of image-based media entities via display formatter. The image style, custom classes, and other HTML attributes can be specified directly in a new formatter for media reference fields.
- Making it easier to output file-based media entities like image- and video- based media entities in Twig. The image style, custom classes, and other HTML attributes can be specified directly in Twig. Cache metadata for the media is handled automatically.
The `media_helper` service that powers the additional formatter and Twig functions provides public methods that can assist with programmatic rendering.