The Problem – Images on divi webpage serving single image size irrespective of devices sizes
- Is your divi webpage slow?
- Do the <img> tags serve a single size irrespective of the device size?
A responsive image offers different
sizes of the same image. The browser decides the best image size to render.
The non-responsive image have a single image size. The same image loads on large desktop, tablet and mobiles.
Let's say you use the native divi image module with image of size 2000px. Serving the 2000px wide image on a device with width 400px serves no purpose other than to slow down the webpage.
The Solution – Divi responsive image size plugin
The Divi Responsive Image Size plugin has two modules.
- Responsive Image divi module – It's available in regular divi section
- Fullwidth Responsive Image divi module – It's available in fullwidth divi section.
Both the modules help creates a image tag with responsive image sizes.
A responsive image adds the
sizes attributes to the image markup.
Consider the example of an <img> tag
<img alt="Divi responsive image sizes" src="default.jpg" srcset="small.jpg 240w, medium.jpg 300w, large.jpg 720w" sizes="(max-width: 360px) 300px, 100vw">
Let's go over each attribute.
alt="Divi responsive image sizes"
alt attribute describes the alternative text for the image. Browser loads this text when it can't find the image.
src attribute defines a fallback image path for browsers that don't support
srcset="small.jpg 240w, medium.jpg 300w, large.jpg 720w"
srcset attribute lists images at different sizes. Along with each image path we specify it's width in pixels.
sizes="(max-width: 360px) 300px, 100vw"
sizes attribute instructs the browser on how to pick the right image from the
srcset based on the
viewport (device) size.
Going by the above example,
- For viewport size 360px and below, browser displays medium.jpg (300px) image.
- For viewport size above 360px, browser displays large.jpg image that is 720px wide.
Divi image sizes
Divi supports following css media breakpoints.
- Large screens (1405px upwards)
- Laptops and desktops (between 1100px and 1405px)
- Tablets in landscape mode (between 981px and 1100px)
- Tablets in portrait mode (between 768px and 980px)
- Smart phones in landscape mode (between 480px and 768px)
- Smart phones in portrait mode (between 0 and 479px)
For every breakpoint, the responsive divi modules has a corresponding field to set the image width.
- Image section – Upload/select an image, set
figcaptiontags. If alt and caption values are empty, it uses corresponding values from WordPress media attachment.
- Responsive Image Width section – Define the image sizes at different media breakpoints.
- Caption Text section – Add custom style to the caption text.
- Sizing section – Change the max and standard width for the <figure> element.
- Spacing section – Set the padding and margin values for the figure
- Border section – Set border styles for the <img> tag.
- Box shadow section – Set box shadow styles for the <img> tag.
- Filters section – Set filters for the figure element.
- Transform section – Set transforms for the figure element
- CSS ID & Classes section – Set css id and classes for figure element
- Custom CSS section – Add custom css for <figure>, <img> and <figcaption> tags
- Visibility section – Set visibility for the <figure> tag on desktop, tablet and mobile.
Improve image SEO score
Image SEO is important. The responsive divi modules follows google recommendations for image SEO
- The responsive divi modules wraps the image in a <figure> tag.
- It can display a caption for the image using the <figcaption> tag.
altattribute text is got from the WordPress media attachment or custom text.
Full divi frontend builder support
The Responsive Image and Fullwidth Responsive Image divi modules provide full divi frontend builder support. Add custom styles to the image and caption text via the modules