Wordpress 4.4:从functions.php更改media.php中的max_srcset_image_width

Wordpress 4.4:从functions.php更改media.php中的max_srcset_image_width,wordpress,hook,srcset,Wordpress,Hook,Srcset,Wordpress使用以下行定义media.php中新srcset属性中包含的最大分辨率: $max_srcset_image_width = apply_filters( 'max_srcset_image_width', 1600, $size_array ); 有没有办法(通过hook等)从mythemes functions.php更改该值?现在,我在media.php本身中对其进行了更改(这是不推荐的–我知道…。我成功地将其添加到我的functions.php文件中 function

Wordpress使用以下行定义media.php中新srcset属性中包含的最大分辨率:

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

有没有办法(通过hook等)从mythemes functions.php更改该值?现在,我在media.php本身中对其进行了更改(这是不推荐的–我知道…。

我成功地将其添加到我的functions.php文件中

function new_srcset_max($max_width) {
    return 2000;
}

add_filter('max_srcset_image_width', 'new_srcset_max');

工作起来很有魅力!谢谢你,先生