前言
环境
1. centos7.0 64位
2. PHP 7.0.13
网站运行已有半月,一直很单调,整个版面几乎无图片,用了些许时间,终于找齐了十几张自认为萌萌哒的图片,裁剪,上传,再开启显示缩略图功能,天真的以为,以后网站就会由一个丑八怪变得不那么难看了。然而,还是我太年轻啊。
解决wordpress不能显示缩略图
最开始以为图片位置上传错误,然后去看,发现并没有
于是乎,F12,找到出错连接,在新的窗口打开,然后就会看到这样的报错信息
A TimThumb error has occured The following error(s) occured: Could not create the index.html file - to fix this create an empty file named index.html file in the cache directory. Could not create cache clean timestamp file. Query String : src=http://my.domain.com/wp-content/themes/mytheme/img/pic/2.jpg&h=120&w=160&q=90&zc=1&ct=1 TimThumb version : 2.8.13
提示也很明确:
1. 不能创建index.html文件,要修复的话,就要在cache目录下创建一个空的名为index.html的文件
2. 不能创建缓存清理时间戳文件
既然这样,就进入cache目录,发现恰好有这样的文件
备份之后删除
重试,又出现
A TimThumb error has occured The following error(s) occured: GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library Query String : src=http://my.domain.com/wp-content/themes/mytheme/img/pic/2.jpg&h=120&w=160&q=90&zc=1&ct=1 TimThumb version : 2.8.13
就是说当前的主机环境并没有安装GD library(图形处理模块)
Linux下为PHP添加GD库
安装步骤
1. 在centos中可以采用yum
的方式安装
[root@VM_112_250_centos themes]# yum install php-gd
之后根据提示安装php-gd
以及 其余依赖即可
另外:
采用yum
方式安装之后,并不需要再手动更改php.ini
文件为其添加extension=gd.so
,
因为这种方式安装会自动的创建一个/etc/php.d/gd.ini
文件,内容是extension=gd.so
,
系统会自动把/etc/php.d/这个目录下的*.ini读入php.ini
查找gd.so文件
[root@VM_112_250_centos ~]# find / -name gd.so /usr/lib64/php/modules/gd.so
2. 安装之后重启web服务器(这里是apache)
[root@VM_112_250_centos themes]# service httpd restart
在windows中,需要找到php.ini
,取消extension=php_gd2.dll
的注释即可
安装GD库之后,如果没有其余的问题,我们的缩略图应该就可以正常的显示了。
本文固定链接:心知博客 » 解决wordpress不能显示缩略图的问题
本站内容除特别标注外均为原创,欢迎转载,但请保留出处!