最新消息:yaf表单扩展中新增加了浮点数、日期和集合的校验。php yaf框架扩展实践三——表单

wordpress上传图片后自动生成很多张缩略图的问题

PHP 3663浏览 1评论

在使用wordpress一段时间后,发现服务器空间使用量涨的有点快,觉的很奇怪,就查了下原因,发现是上传图片的问题,每上传一张图片就会生成好多张的缩略图,难怪涨的这么快。如下图:

wordpress生成多张缩略图

wordpress生成多张缩略图

因为站点不需要显示这么多图片,只需要原图就OK了,所以就要修改下媒体设置。打开设置->媒体,将不需要的缩略图宽度高度都设置为0就可以了。如下图:

wordpress缩略图设置

wordpress缩略图设置

但是这样设置之后,还是会生成其它分辨率的缩略图,笔者猜测应该是主题的问题,于是就去主题内查找,笔者用的主题是themolio。后来在主题文件的functions.php中找到了这样的代码:

function themolio_setup() {

    /* Make Themolio available for translation.
      * Translations can be added to the /languages/ directory.
      * If you're building a theme based on Themolio, use a find and replace
      * to change 'themolio' to the name of your theme in all the template files.
    */
    load_theme_textdomain('themolio', get_template_directory().'/languages' );
    add_editor_style();
    add_theme_support('automatic-feed-links');
    add_theme_support('post-thumbnails');

    /**
     * This sets up the image size for the grid based top-down layouts (with no sidebar).
     * If you change the width/height of your content,
     * you will have to modify the width and height mentioned below as well
     */
    add_image_size('themolio-two-col-grid-image-nosidebar',460,300,true);
    add_image_size('themolio-three-col-grid-image-nosidebar',290,200,true);
    add_image_size('themolio-four-col-grid-image-nosidebar',210,150,true);

    /**
     * This sets up the image size for the grid based top-down layouts (with sidebar).
     * If you change the width/height of your content,
     * you will have to modify the width and height mentioned below as well
     */
    add_image_size('themolio-two-col-grid-image-sidebar',356,250,true);
    add_image_size('themolio-three-col-grid-image-sidebar',230,150,true);
    add_image_size('themolio-four-col-grid-image-sidebar',171,110,true);

    /**
     * This sets up the image size for the featured image.
     * If you change the width/height of your content,
     * you will have to modify the width and height mentioned below as well
     */
    add_image_size('themolio-featured-image',800,300,true);

    register_nav_menu('primary', __('Primary Menu', 'themolio'));

    add_theme_support('post-formats', array('link', 'gallery', 'status', 'quote', 'image', 'video'));

    if(themolio_is_wp_version('3.4')) {
	add_theme_support('custom-background');
    } else {
	add_custom_background();
    }
}

其中add_image_size就是增加缩略图设置的方法,根据需要注释掉即可。其它主题也可以依此类推,只要搜索关键词add_image_size,应当就能找到缩略图的设置。

最后生成多张缩略图的问题就搞定了。

友情提示

如果日后有需要缩略图,可以在媒体->媒体库->选择需要的图片点编辑->编辑图片,然后就可以裁剪图片了。最后报下wordpress和使用主题的版本:

转载请注明:快乐编程 » wordpress上传图片后自动生成很多张缩略图的问题

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. 没发现这种问题。
    xiaomingtt5年前 (2012-12-28)回复