Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to disable responsive images in WordPress 4.4

The latest version of Wordpress, 4.4 (“Clifford”), has rolled out a feature whereby it adds ‘srcset’ attributes to all image tags in order that browsers can decide which image to load if various resolutions are available.

This is all well and good, but (a) you may not want these new attributes in your Code for a variety of reasons, and (b) conflicts with some plugins and themes are being reported.

In either case, you may need an easy way to Disable the feature, for the time being at least.

Here is such a way, courtesy of StackExchange user Birgir Erlendsson.

add_filter('wp_get_attachment_image_attributes', function($attr) {
    if (isset($attr['sizes'])) unset($attr['sizes']);
    if (isset($attr['srcset'])) unset($attr['srcset']);
    return $attr;
add_filter('wp_calculate_image_sizes', '__return_false', PHP_INT_MAX);
add_filter('wp_calculate_image_srcset', '__return_false', PHP_INT_MAX);
remove_filter('the_content', 'wp_make_content_images_responsive');

Just add this code to your theme’s functions.php file and you’re done. But make sure you’re running PHP 5.3 or later before adding it.

This post first appeared on ZigPress, please read the originial post: here

Share the post

How to disable responsive images in WordPress 4.4


Subscribe to Zigpress

Get updates delivered right to your inbox!

Thank you for your subscription