【发布时间】:2017-06-07 10:28:43
【问题描述】:
在最近的 wordpress 版本中,添加了一个新的默认中间尺寸“medium_large”,以更好地利用响应式图像支持。新尺寸默认为 768px 宽,没有高度限制。
在选择要在帖子中插入的图像时,UI 中不包含 medium_large 尺寸,也不包含用于从媒体设置页面更改图像大小的 UI。但是,开发人员可以使用 update_option() 函数修改此新尺寸的宽度,类似于任何其他默认图像尺寸。
用法:
<?php update_option( $option, $new_value, $autoload ); ?>
考虑到我已经尝试通过functions.php文件中的以下代码编辑默认的medium_large图像大小但没有成功,请您帮我通过update_option构建代码,如上所述?
function filter_image_resize_dimensions( $payload, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
if ( $orig_h > 200 ) {
$new_w = 200;
$new_h = auto;
}
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
} add_filter('image_resize_dimensions', 'filter_image_resize_dimensions', 10, 6);
【问题讨论】: