WordPress 4.4: Change max_srcset_image_width in media.php from functions.php

WordPress defines the maximum resolution included in the new srcset attribute in the media.php with the following line:

$max_srcset_image_width = apply_filters( 'max_srcset_image_width', 1600, $size_array );

Is there any way to change that value (via hook etc) from my themes functions.php? Right now I changed it in the media.php itself (which is not recommended – I know…).

Related posts

1 comment

  1. I had success adding this to my functions.php file

    function new_srcset_max($max_width) {
        return 2000;
    }
    
    add_filter('max_srcset_image_width', 'new_srcset_max');
    

Comments are closed.