Cloudimage - Documentation

Responsive Images made easy

Responsive images adapt the image size according to the screen size of the end user, thereby allowing your website or mobile app to load faster across various screen sizes. For example, on an iPhone, Cloudimage will deliver smaller images than it would on a 15" computer screen, thus accelerating the page loading time.

The HTML <picture> element with the underlying <source> elements allow to specify which image size will be delivered to which screen size. Examples below.

Without responsive design

The following HTML code delivers the same image size (800x180px) to all screen sizes (15" laptop monitor, iPad, smartphone, ...)

<img src="" />

This image size might be optimized for 13" screens but is too large for 4" smartphone screens, where it would be better delivered in 400x90px. To achieve this, HTML 5 introduced the <picture> element to give developers more flexibility with image resources.

With responsive design

The following code must replace the <img> element above to make your website or app responsive. It also takes into account high-resolution screens such as Retina: 1.5x, 2x, 3x.

<source media="(max-width:576px)" srcset=" 1x, 1.5x, 2x, 3x">
<source media="(max-width:768px)" srcset=" 1x, 1.5x, 2x, 3x">
<source media="(max-width:992px)" srcset=" 1x, 1.5x, 2x, 3x">
<source media="(max-width:1200px)" srcset=" 1x, 1.5x, 2x, 3x">
<source media="(max-width:1920px)" srcset=" 1x, 1.5x, 2x, 3x">

The <picture> tag is compatible with the following browsers.

As you can see, implementing the <picture> element is cumbersome. Therefore, the Cloudimage team has developed a JS plugin to automate everything for you. Check it out here as well as a demo.