WordPress disable responsive images

Disable or remove WordPress responsive image markup

WordPress 4.2 introduced so-called “native” responsive image markup that uses srcset and sizes attribute. It’s applied to all images in order to server images better for different screen sizes.

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 using code

You can remove the WordPress srcset and size responsive markup from your WordPress website by editing the functions.php file of your theme and adding this code at the appropriate position:

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

You can also 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');

You can also remove the WordPress responsive image markup using plugin.

Davor Veselinovic

Being web developer for more than 15 years should tell you quit enough. I'm in love with WordPress for over a decade now and I have pretty neat and huge WordPress experience. I have created some free themes and plugins for WordPress and I do like to share my knowledge with others. :)

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Meks WordPress Themes


NEWSLETTER

Your Header Sidebar area is currently empty. Hurry up and add some widgets.