WordPress默认不关闭上传以上图片会生成多个版本的缩略图,不管你用不用,时间久了网站Ftp占用爆表。建议禁用WordPress默认生成缩略图功能。
禁用方法
将下边的代码放到主题 functions.php 文件内即可生效
// 禁用自动生成的图片尺寸
function shapeSpace_disable_image_sizes($sizes) {
unset($sizes['thumbnail']);// disable thumbnail size
unset($sizes['medium']);// disable medium size
unset($sizes['large']);// disable large size
unset($sizes['medium_large']);// disable medium-large size
unset($sizes['1536x1536']);// disable 2x medium-large size
unset($sizes['2048x2048']);// disable 2x large size
return $sizes;
}
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');// disable images added via set_post_thumbnail_size()
remove_image_size('another-size');// disable any other added image sizes
}
add_action('init', 'shapeSpace_disable_other_image_sizes');
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(1)
6666666666666666牛逼