Advertising sustains the DA. Ads are hidden for members. Join today

Contributed module documentation

Responsive Background Image

This is a very simple module that provides a method to call programmatically from within a preprocess function, that will generate CSS media queries for a responsive background image for a specific CSS selector. This will allow you to display an image from an image field, on a particular HTML tag/element as a background image, and serve a specific image file depending on the browser window width, or the device pixel ratio. It uses Drupal core Responsive Image Styles to generate the media queries and image paths. It supports the classic Image field and the newer Media field of type Image.

The method provided by this module will return an array ready to be attached to the HTML <head> as a <style> tag. Please note there is no UI for this module. It simply provides a method that can be called programmatically from within a preprocess function.

How to use the Responsive Background Image module

How to use the Responsive Background Image module.

Guide maintainers

maskedjellybean's picture