WordPress默认不关闭上传以上图片会生成多个版本的缩略图,不管你用不用,时间久了网站Ftp占用爆表。建议禁用WordPress默认生成缩略图功能。

禁用方法

将下边的代码放到主题 functions.php 文件内即可生效

  1. // 禁用自动生成的图片尺寸
  2. function shapeSpace_disable_image_sizes($sizes) {
  3. unset($sizes['thumbnail']);// disable thumbnail size
  4. unset($sizes['medium']);// disable medium size
  5. unset($sizes['large']);// disable large size
  6. unset($sizes['medium_large']);// disable medium-large size
  7. unset($sizes['1536x1536']);// disable 2x medium-large size
  8. unset($sizes['2048x2048']);// disable 2x large size
  9. return $sizes;
  10. }
  11. add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_image_sizes');
  12. // 禁用缩放尺寸
  13. add_filter('big_image_size_threshold', '__return_false');
  14. // 禁用其他图片尺寸
  15. function shapeSpace_disable_other_image_sizes() {
  16. remove_image_size('post-thumbnail');// disable images added via set_post_thumbnail_size()
  17. remove_image_size('another-size');// disable any other added image sizes
  18. }
  19. add_action('init', 'shapeSpace_disable_other_image_sizes');
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。