解决TimThumb生成站外缩略图出错 A TimThumb error has occured

wordpress网站因为网络问题使用站外的域名,导致缩略图出现 “A TimThumb error has occured”

wordpress网站因为网络问题使用站外的域名,导致缩略图出现 “A TimThumb error has occured”

错误信息展示案例如下:
A TimThumb error has occured
The following error(s) occured:
You may not fetch images from that site. To enable this site in timthumb, you can either add it to $ALLOWED_SITES and set ALLOW_EXTERNAL=true. Or you can set ALLOW_ALL_EXTERNAL_SITES=true, depending on your security needs.

Query String : w=280&h=160&a=c&zc=1&q=90&src=https://xxxxx.creplus.cn/uploads/2897e30fee232a65a2ab75f606fbcc27.webp
TimThumb version : 2.8.14

错误原因:当前的WordPress主题中是有TimThumb图片缩略图功能的,默认情况阻止外部域名的使用。常见的解决方法就是更改timthumb.php文件ALLOW_ALL_EXTERNAL_SITES选项为true

如果不知道如何寻找timthumb.php文件位置,可以在wordpress 网站根目录运行如下命令

grep -rn 'ALLOW_ALL_EXTERNAL_SITES' ./

编辑timthumb.php,找到ALLOW_ALL_EXTERNAL_SITES,把值改为ture即可,有些文件可能没有直接的写入权限,增加sudo 提高权限写入并保存。

timthumb 相关链接

插件讨论: https://wordpress.org/support/plugin/timthumb/

github:https://github.com/GabrielGil/TimThumb

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注