Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

cs_adaptive_image

999 sites Security covered
View on drupal.org

The Client-side adaptive image module helps build responsive web designs with fluid images by providing an Image field formatter that allows you to select appropriate image styles for various client widths. With this module, you can ensure that for each Image field only the most appropriately sized image gets downloaded by the client.

You can serve light images to mobile users while still providing the best quality images to visitors equipped with large screens.

Some highlights:

  • Per-field configuration (for each view mode).
  • Relies on JavaScript but provides a clean fallback for clients lacking it.
  • No cookies required.
  • No external libraries required.
  • No extra server configuration needed.
  • Does not attempt to perform any client OS detection.
  • Reverse proxy cache friendly.

How it works

Image selection rests solely on the client's side, hence the name of the module. Unlike some other adaptive image techniques, the server takes no part in the image selection process. Instead, the module provides the list of candidate images during page generation, and the client picks the right one through JavaScript (or through a fallback if JavaScript is not enabled).

The technique used by this module was inspired by Mairead Buchan's article Creating responsive images using the noscript tag and her finding that children of the <noscript> tag are rightfully not added to the DOM when JavaScript is enabled.

What the module does is basically this:

  • Wrap a fallback image in a <noscript> element.
  • Attach references to alternate images to the <noscript> element using data attributes. Data attributes are an HTML5 feature but work in older browsers as well.
  • Using JavaScript, retrieve the client's width, pick the right image from the data attributes, and insert it in the document after the <noscript> element. Note that we're referring to the client's width rather than the document's width or the window's width. That's because the width is retrieved using the document.documentElement.clientWidth property, which behaves inconsistently across browsers.
  • Watch for window resize events, and replace the images when appropriate.

Similar projects

You might be interested in the following Drupal modules, which provide similar functionality using different techniques and/or architectures:

Credits

This project has been sponsored by: Whisky Echo Bravo

Activity

Total releases
2
First release
Sep 2025
Latest release
6 months ago
Release cadence
0 days
Stability
50% stable

Releases

Version Type Release date
2.0.x-dev Dev Sep 20, 2025
7.x-1.2 Stable Sep 20, 2025