Responsive web design is a method of designing websites to provide an optimal viewing experience to users, irrespective of the device, window size, orientation, or resolution used to view the website. A site designed responsively adapts its layout to the viewing environment, resizing and moving elements dynamically and based on the properties of the browser or device the site is being displayed on.
The responsive web design uses CSS for dynamic content changes and controlling the text font size, the layout grid used and the various image dimensions, which are based on media queries and the browser window size. Most of the dynamic changes can be accomplished this way (or with frameworks like Bootstrap) but not so when it comes to the images.
When it comes to images, a responsively designed website should not just send a high-resolution image and then use browser resizing to display the image on various devices: that would be a huge waste of bandwidth for users on small, low-resolution displays. To serve as a responsive image, a version of the image should be created in different resolutions, so that devices can load only the relevant image data
Cloudinary can help reduce the complexity with dynamic image and video manipulation. You can simply build image URLs with any image width or height based on the specific device resolution and window size. This means you don't have to pre-create the images, with dynamic resizing taking place on-the-fly as needed.
A Cloudinary dynamic manipulation URL is automatically built on the fly to deliver an uploaded image that is scaled to the exact available width.
If the browser window is consequently enlarged then new higher resolution images are automatically delivered, while using stop-points (every 100px by default) to prevent loading too many images.
If the browser window is scaled down, browser-side scaling is used instead of delivering a new image.
This feature allows you to provide one high resolution image, and have it automatically adapted to the resolution and size appropriate to each user’s device or browser on the fly. This ensures a great user experience by delivering the best possible resolution image, based on the device's resolution and the width available, without needlessly wasting bandwidth or loading time.
Implementing the responsive web design in code using the Cloudinary jQuery plugin is a very simple process.
Include the jQuery plugin in your HTML pages (see the jQuery plugin getting started guide for more information).
For each image to display responsively:
data-srcattribute of the
imgtag to the URL of an image that was uploaded to Cloudinary. The
srcattribute is not set and the actual image is updated dynamically (you can set the src attribute to a placeholder image that is displayed until the image is loaded).
w_autoin URLs). This allows the jQuery plugin to dynamically generate an image URL scaled to the correct width value, based on the detected width actually available for the image in the containing element.
cld-responsiveclass to the image tag. This is the default class name, but you can use custom class names and programmatically make HTML elements become responsive.
<img data-src="https://res.cloudinary.com/demo/image/upload/w_auto/smiling_man.jpg" class="cld-responsive">
responsive method looks for all images in the page that have the "cld-responsive" class name, detects the available width for the image on the page, and then updates the HTML image tags accordingly. The image is also updated whenever the window size or screen resolution changes.
Thats it! Checkout the following demo images created using Cloudinary (for the images) and Bootstrap (for the layout). The images also include a text overlay that is updated on-the-fly to display the actual width of the image and the Device Pixel Ratio setting (see further on in this blog post for more details on DPR).
Resize this browser window to see how the layout and images dynamically respond to the changes.
As can be seen in the demo images above, the URL of an image can be further manipulated on the fly like any other image uploaded to Cloudinary.
To make things even easier, responsive web design can be implemented with the Cloudinary SDK's view helper methods (e.g.
cl_image_tag in Ruby on Rails). Setting the
width parameter to
auto creates an HTML image tag with a blank
src attribute while the
data-src attribute points to a dynamic image manipulation URL. When you load Cloudinary's jQuery plugin and call the
responsive method, the image tags are automatically updated and URLs are replaced with the correct width value. You can also set a placeholder image using the
responsive_placeholder parameter, or set it to an inline blank image by setting the parameter to
For example, creating an HTML image tag for the "smiling_man.jpg" image with the width automatically determined on the fly as needed, and using a blank image placeholder:
The code above generates the following HTML image tag:
<img class="cld-responsive" data-src="https://res.cloudinary.com/demo/image/upload/w_auto/smiling_man.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />
You can also simultaneously create the correct DPR image for devices that support higher resolutions by simply adding the
dpr parameter set to
For example, creating an HTML image tag for the "woman.jpg" image with the width and DPR automatically determined on the fly as needed, and using a blank image placeholder:
The code above generates the following HTML image tag:
<img class="cld-responsive" data-src= "https://res.cloudinary.com/demo/image/upload/w_auto,dpr_auto/woman.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />
In the modern world, applications have to look good on both the web and on various mobile devices, and therefore need to become more responsive to support the large number of devices available and adjust to the varying amount of space available for displaying content. Responsive frameworks such as Bootstrap can help with the layout and text, but have no support for images beyond client-side resizing.
Responsive support is available in all the Cloudinary plans, including the free plan. If you don't have a Cloudinary account, you are welcome to sign up to our free account and try it out.
Update - See our other blog posts on responsive web design:
- Responsive images with Cloudinary
- Introducing intelligent responsive image breakpoints solutions
- Responsive design images with 'srcset', 'sizes' and Cloudinary
- Auto-Crop Images for Responsive Designs and Improved Image Quality
- Automatically art-directed responsive design images
- Push-button Art Direction
- Responsive design Images Guide, Part 1
- Responsive design Images Guide, Part 2
- Responsive design Images Guide, Part 3
- Responsive design Images Visual Web resource.
- Make All Images on Your Website Responsive in 3 Easy Steps
- Best Practices for Responsive Web Design