Posted on

WordPress禁用缩略图和图片裁剪函数

将以下代码添加至主题functions.php文件中,适用WordPress 5.3以上版本。

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']);
}
add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_image_sizes');
add_filter('big_image_size_threshold', '__return_false');
function shapeSpace_disable_other_image_sizes() {
remove_image_size('post-thumbnail');
}
add_action('init', 'shapeSpace_disable_other_image_sizes');
参考引用
  1. 代码引用:彻底禁止WordPress的图片自动生成多个尺寸 [梨数码版权所有,转载标明出处]
  2. 图片引用:互联网

Leave a Reply

Your email address will not be published. Required fields are marked *