Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module provides an image field formatter that allows you to select different image sizes based on the user's screen width. It ensures users download the most appropriately sized image, serving smaller images to mobile devices and higher quality images to larger screens, without requiring server configuration or external libraries.

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
9 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Slowing

Releases

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