wordpress disable responsive images 1

How to disable or remove WordPress responsive image markup

Davor 02/09/2018

WordPress 4.2 introduced a so-called “native” responsive image markup that uses “srcset” and sizes attribute. It’s applied to all images of your blog to serve appropriate thumbnails and images based on the device screen size.

Sometimes you might need to remove WordPress responsive image markup for various purposes and here is the way how to remove or disable it.

Removing WordPress responsive image markup via functions.php

Easily remove the WordPress srcset” and size responsive markup from your WordPress website by editing the functions.php file of your theme.

Add this small code snippet inside the functions.php file, before the ending php tag:

function disable_srcset( $sources ) 
{ return false; } 
add_filter( 'wp_calculate_image_srcset', 'disable_srcset' );

 

To prevent WordPress from creating a new medium_large thumbnail in 768px, you will need to add this code to the functions.php file as well.

function ta_customize_thumbnail_sizes($sizes) { 
unset($sizes['medium_large']); // 768px return $sizes; 
} 
add_filter('intermediate_image_sizes_advanced', 'ta_customize_thumbnail_sizes');

After you apply this small tweak, your WordPress website should stop adding responsive markup to the images tag of your blog’s code.

Davor Veselinović

I'm Davor, founder of Worda Themes. Working as a Full Stack Developer with more than a decade of experience with WordPress. I build themes and plugins and enjoy writing useful blog posts and share my ideas with others.

Leave a Reply

Your email address will not be published. Required fields are marked *