【问题标题】:Using timthumb on WordPress , still not working:(( . Help,please在 WordPress 上使用 timthumb,仍然无法正常工作:((。请帮助
【发布时间】:2011-05-07 06:53:04
【问题描述】:

这是我的网站,其中 timthumb 无法正常工作:“http://vitinh.cz/?page_id=8” 我已经尝试了很多解决方案,但什么都没有......而且我还在您的网站(http://andrewroycarter.com/wordpress-2/using-timthumb-on-wordpress-multi-user/)中使用了您的提示。 但无论如何我都无法让它工作:(。你能帮我解决它吗?谢谢。 期待您的回复。

(Wordpress 版本 3.0.1)

【问题讨论】:

  • “不工作”不是问题描述。如果您不进行一些调试并告诉我们具体细节,您将无法回答这个问题。

标签: php wordpress


【解决方案1】:

问题是您正在尝试使用 timthumb.php 来调整不在您服务器上的图像的大小。

调整大小图像的实际错误是这样的:

不允许远程主机“ongmat.cz” TimThumb 版本:1.14

解决方案是编辑 timthumb.php 脚本并更改第 24 行(或接近它)

 // external domains that are allowed to be displayed on your website
$allowedSites = array (
        'flickr.com',
        'picasa.com',
        'blogger.com',
        'wordpress.com',
        'img.youtube.com',
);

并添加您要从中使用图像的域,例如将 ongmat.cz 添加到数组中,使其看起来像这样:

  $allowedSites = array (
                'flickr.com',
                'picasa.com',
                'blogger.com',
                'wordpress.com',
                'img.youtube.com',
                'ongmat.cz',
        );

或者您可以更改此选项(虽然不那么安全)

define ('ALLOW_EXTERNAL', FALSE);                       // allow external website (override security precaution)

并将 FALSE 更改为 TRUE

前 30 行应如下所示:

/**
 * TimThumb script created by Ben Gillbanks, originally created by Tim McDaniels and Darren Hoyt
 * http://code.google.com/p/timthumb/
 * 
 * GNU General Public License, version 2
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 *
 * Examples and documentation available on the project homepage
 * http://www.binarymoon.co.uk/projects/timthumb/
 */

define ('CACHE_SIZE', 250);                                     // number of files to store before clearing cache
define ('CACHE_CLEAR', 5);                                      // maximum number of files to delete on each cache clear
define ('CACHE_USE', FALSE);                            // use the cache files? (mostly for testing)
define ('VERSION', '1.16');                                     // version number (to force a cache refresh)
define ('DIRECTORY_CACHE', './cache');          // cache directory
define ('DIRECTORY_TEMP', './temp');            // temp directory
define ('MAX_WIDTH', 1000);                                     // maximum image width
define ('MAX_HEIGHT', 1000);                            // maximum image height
define ('ALLOW_EXTERNAL', TRUE);                       // allow external website (override security precaution)

// external domains that are allowed to be displayed on your website
$allowedSites = array (
        'flickr.com',
        'picasa.com',
        'blogger.com',
        'wordpress.com',
        'img.youtube.com',
        'ongmat.cz',
);

【讨论】:

  • 那么你很可能做错了什么。这绝对是问题所在,因为我以前遇到过。可以发一下这个文件的前 30 行吗:vitinh.cz/wp-content/themes/vitinh/timthumb.php
  • if(!function_exists('imagecreatetruecolor')) { displayError('GD 库错误:imagecreatetruecolor 不存在 - 请联系您的虚拟主机并要求他们安装 GD 库');} define ('缓存大小',250);定义('CACHE_CLEAR',5);定义('版本','1.14');定义('DIRECTORY_CACHE','./cache');定义('DIRECTORY_TEMP','./temp'); $allowedSites = array ('flickr.com', 'picasa.com', 'blogger.com', 'wordpress.com', 'img.youtube.com', 'ongmat.cz', );对不起,我不能像你一样发帖
  • 或者,您可以将图像上传到您自己的博客并以这种方式链接到它们。
  • 我已经添加了与上面完全相同的内容,但没有任何反应:(
  • 创建文件的备份副本,然后将代码行替换为我粘贴的代码行,看看是否可以解决问题。如果没有,请放回备份副本
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-14
  • 1970-01-01
  • 2011-11-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多