Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Easy Responsive Images

Security covered Under active development 1,652 sites

This module simplifies responsive images by automatically generating image styles based on defined aspect ratios and widths. It then provides tools to integrate these styles into your theme, enabling optimized image loading for different screen sizes.

When using media to add images to content, having media view modes defined by aspect ratio, combined with a bunch of different image styles for the images in that specific aspect ratio solves the responsive images problem in the easiest way possible.

Easy Responsive Images needs a minimum and maximum width, in combination with a preferred amount of pixels between each image style. An optional list of aspect ratio's can also be defined. When the configuration is saved, the image styles are automatically generated. For example generating image styles for a 4:3 ratio and 16:9 ratio will produce the following styles:

  • responsive_4_3_50w
  • responsive_16_9_50w
  • responsive_4_3_150w
  • responsive_16_9150w
  • …
  • responsive_4_3_1450w
  • responsive_16_9_1450w

Usage

After generating the desired image styles for the different aspect ratio's, create a media view mode for each aspect ratio. This can be done using the Easy Responsive Images formatter, but module provides a Twig filter to create URLs for the images styles (including an optimized WebP version of the image when using
ImageAPI Optimize WebP or WebP).

Create a template for your media view mode, eg. media--image--16-9.html.twig for a 16_9 view mode, containing the following code:

{#
/**
 * @file
 * Default theme implementation to display an image.
 */
#}
{{ attach_library('easy_responsive_images/resizer') }}

{% set file = media.field_media_image.entity %}
{% set src = file.uri.value|image_url('responsive_16_9_50w') %}
{% set srcset = [
  file.uri.value|image_url('responsive_16_9_150w') ~ ' 150w',
  file.uri.value|image_url('responsive_16_9_350w') ~ ' 350w',
  file.uri.value|image_url('responsive_16_9_550w') ~ ' 550w',
  file.uri.value|image_url('responsive_16_9_950w') ~ ' 950w',
  file.uri.value|image_url('responsive_16_9_1250w') ~ ' 1250w',
  file.uri.value|image_url('responsive_16_9_1450w') ~ ' 1450w',
] %}
<img src="{{ src }}" data-srcset="{{ srcset|join(',') }}" alt="{{ media.field_media_image.alt }}" loading="lazy" />

Each time media is displayed using the view mode, the JavaScript will check the
available width for the image container, and load the optimized image style.
Also notice the HTML5 "loading" attribute to enable lazy loading of images for
even more optimization.

Supported modules

This module works even better in combination with:

It also supports external images via Imagecache External.

Drupal 10–11

Ask your assistant about Easy Responsive Images

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • image Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Oct 2023
Latest release
1 month ago
Releases (12 mo)
1
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
1.6.0 Stable 10–11 Aug 25, 2026
1.5.0 Stable 10–11 Jul 18, 2025
1.4.0 Stable 10–11 Aug 19, 2024
1.3.3 Stable 9–10 Dec 23, 2023
1.3.2 Stable 9–10 Oct 11, 2023