3

我在使用此版本的 Timthum 时遇到以下问题:2.8.10(在 Wordpress 安装上运行 - 服务器 Ubuntu):

- 当我从托管网站的服务器调用图像时,出现此错误:

发生 TimThumb 错误 发生以下错误:

Could not find the internal image you specified.

查询字符串:src=http://my-host.it/wp-content/files_mf/1346848579prog_no_pic.png TimThumb 版本:2.8.10

如果我在浏览器中复制/粘贴http://my-host.it/wp-content/files_mf/1346848579prog_no_pic.png我可以获得图像...

- 当我从外部站点调用图像时,它工作正常。 我已启用:

define ('ALLOW_ALL_EXTERNAL_SITES', TRUE);

在第 33 行。

4

5 回答 5

3

对我来说,由于我的虚拟主机设置,文档根目录的设置不正确。

我必须在其中添加正确的timthumb-config.php

define('LOCAL_FILE_BASE_DIRECTORY', "/home/www/mysite/");
于 2013-03-06T18:27:22.893 回答
2

这两个步骤对我有用:

  • 在 ~33 行中设置为ALLOW_ALL_EXTERNAL_SITES:

if(! defined('ALLOW_ALL_EXTERNAL_SITES') ) define ('ALLOW_ALL_EXTERNAL_SITES', TRUE);

  • 评论行~212

//$this->src = preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '', $this->src);


来源: https ://code.google.com/p/timthumb/issues/detail?id=363#c23

于 2014-08-04T20:39:44.113 回答
1

我在 WordPress (3.5.1) 的多站点安装中遇到了同样的问题。以下修复了它:

functions.php中改变

function get_image_url($img_src="") {
if($img_src!="") $theImageSrc = $img_src;
else $theImageSrc = wp_get_attachment_url(get_post_thumbnail_id($post_id));
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
    $imageParts = explode('/files/', $theImageSrc);
    if (isset($imageParts[1])) {
        $theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
    }
}
echo $theImageSrc;

}

function get_image_url($img_src="") {
if($img_src!="") $theImageSrc = $img_src;
else $theImageSrc = strstr(wp_get_attachment_url(get_post_thumbnail_id($post_id)), "/wp-content");
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
    $imageParts = explode('/files/', $theImageSrc);
    if (isset($imageParts[1])) {
        $theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
    }
}
echo $theImageSrc;

}

注意:唯一实际的修改发生在第 3 行(粗体): $theImageSrc = strstr( wp_get_attachment_url(get_post_thumbnail_id($post_id)) , "/wp-content") ;

于 2013-02-24T22:07:27.560 回答
1

我刚刚解决了这个问题,就我而言,这与文件路径中包含波浪号有关。

这是我找到的解决方案的链接:

http://elementdesignllc.com/2012/01/how-to-fix-timthumb-using-a-virtual-directory-url-contains-tildes/comment-page-1/#comment-7418

于 2012-12-18T00:37:31.130 回答
0

首先让我知道您在使用 WordPress Multisite 吗?如果是,那么您不需要在 timthumb.php 中编辑任何内容,我喜欢它

这就是我为使 timthumb 与多站点一起工作所做的工作。您需要将此代码添加到主题的 functions.php 文件中

<?php function get_image_path($src) {
global $blog_id;
if(isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/' , $src);
if(isset($imageParts[1])) {
$src = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
return $src;
}
?>

然后在主题中使用timthumb脚本的地方,需要修改成这样:

<img src="<?php bloginfo('template_url'); ?>/includes/timthumb.php?q=100&w=180&h=200&zc=1&a=t&src=<?php echo get_image_path(get_post_meta($post->ID, 'postImage', true)); ?>" alt="" />

其中 postImage 是包含图像 URL 的元字段的名称。

有一个很好的。

于 2012-12-05T22:33:04.980 回答