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.



Please enter your comment!
Please enter your name here