Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Easy Responsive Images

1,580 sites Security covered Drupal 10–11
View on drupal.org

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.

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
2
Tracked since
Jul 2025
Latest release
6 days ago
Releases (12 mo)
1
Maintenance
Active

Releases

Version Type Core Release date
1.6.0 Stable 10–11 Aug 25, 2026
1.5.0 Stable 10–11 Jul 18, 2025