wordpress上传图片不自动生成缩略图的解决方法

所属分类: CMS教程 / WordPress 阅读数: 2057
收藏 0 赞 0 分享

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



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


复制代码
代码如下:

function themolio_setup() {</p> <p> /* 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');</p> <p> /**
* 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);</p> <p> /**
* 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);</p> <p> /**
* 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);</p> <p> register_nav_menu('primary', __('Primary Menu', 'themolio'));</p> <p> add_theme_support('post-formats', array('link', 'gallery', 'status', 'quote', 'image', 'video'));</p> <p> if(themolio_is_wp_version('3.4')) {
add_theme_support('custom-background');
} else {
add_custom_background();
}
}

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

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

友情提示

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

wordpress是3.4.1版本
主题是Themolio,版本是1.2

更多精彩内容其他人还在看

wordpress wp_list_categories(分类的链接列表)的使用方法

用分类做为导航拦及wp_list_categories的用法,下面是具体的示例,感兴趣的朋友可以参考下哈
收藏 0 赞 0 分享

wordpress通过当前文章的ID获取文章标题内容简介的信息

wordpress通过当前文章的ID获取文章的信息用的极多,在wordpress二次开发中经常会使用到,本文将详细介绍,需要了解的朋友可以参考下
收藏 0 赞 0 分享

wordpress获取当前文章的评论数实现代码

wordpress获取当前文章的评论数,是每一个使用wordpress的朋友所疑惑不解的地方,本文将给出解决方法,可供参考
收藏 0 赞 0 分享

wordpress添加更新数据库等操作提示报错

很长时间没有动过wordpress里的布局了,当我进行添加和更新操作时,连连报错,于是搜集整理一些,拿出来和大家分享
收藏 0 赞 0 分享

WordPress高级自定义布局的内容编辑器(TinyMCE)模板

WordPress的编辑器TinyMCE是一个非常强大的工具,对于网页设计师来说,使用WordPress的编辑器TinyMCE是没什么困难的,但是对于那些不怎么了解HTML的人来说却用起来不是那么的得心应手
收藏 0 赞 0 分享

WordPress手动修改文章排列顺序摆脱按发布时间升降序排列

我们常见的WordPress站点文章排序,通常情况下是按发布时间的升序或降序方式排列,想手动修改文章的排列方式,可以随意更改文章的排列位置这种排序方式几乎可以满足我们的特殊需求了
收藏 0 赞 0 分享

wordpress如何设置文章置顶以及区分置顶文章与普通文章

很多博客都有自己的置顶文章,除了位置差异外,跟其他文章是没有任何区别的,那我们怎样才能将它们区别开来呢,本文将介绍几种方法,需要的朋友可以参考下
收藏 0 赞 0 分享

WordPress插件和主题编写时cookie应如何设置

编写WordPressc插件和主题的时候,经常需要用到cookie,但是如果你在WordPress主题文件中直接使用php的setcookie()来发送cookie,那是完全不行的,我怀疑WordPress初始化的时候已经发送了其他输出,才导致setcookie失效
收藏 0 赞 0 分享

Dreamweaver代码的格式化功能掌控html代码的格式

今天偶然发现了Dreamweaver的一个非常有用的功能,就是代码的格式化功能,我们写的html或者css代码都计较混乱,难以阅读,等到所使用的标签越来越多,嵌套越来越深,这时我们已经很难去掌控html代码的格式问题了
收藏 0 赞 0 分享

如何给wordpress创建动态的置顶文章长时间引起注意

置顶文章的作用是希望长时间引起读者注意,可以表明站点的简介、版权声明、友情链接的交换原则等;本文将介绍如何给wordpress创建动态的置顶文章,需要了解的朋友可以参考下
收藏 0 赞 0 分享
查看更多