禁止WordPress自动剪裁上传图片

怎么样禁止WordPress自动剪裁上传图片?

以下三个步骤:

  1. WordPress设置Settings,媒体Media,所有尺寸调为0
  2. 进入wp-admin/options.php,找到medium_large_size_w设置为0
  3. 可能主题中还有图片剪裁代码,搜索functions.php是否有add_image_size,thumbnails_size没有就不管了,有就注释掉

以上如果还没有效果,试试把一下代码复制到functions.php:

禁用scaled:
add_filter( 'big_image_size_threshold', '__return_false' );

禁用其他大尺寸:
function shapeSpace_disable_image_sizes($sizes) {
unset($sizes['thumbnail']);
unset($sizes['medium']);
unset($sizes['large']);
unset($sizes['medium_large']);
unset($sizes['1536x1536']);
unset($sizes['2048x2048']);
}

这个使用在reflective-vest的Vilva有效
add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_image_sizes');

function shapeSpace_disable_other_image_sizes() {
remove_image_size('post-thumbnail');
remove_image_size('another-size');
}

add_action('init', 'shapeSpace_disable_other_image_sizes');

从上到下,一个一个试吧!

Archived: Job