Wordpress Timthumb:找不到指定的内部映像

Wordpress Timthumb:找不到指定的内部映像,wordpress,timthumb,Wordpress,Timthumb,我对Timthum的这个版本有以下问题:2.8.10(在Wordpress安装服务器Ubuntu上运行): -当我从托管网站的服务器调用图像时,我遇到了以下错误: 发生了一个错误 发生以下错误: 查询字符串:src=http://my-host.it/wp-content/files_mf/1346848579prog_no_pic.png TimThumb版本:2.8.10 如果我在浏览器中复制/粘贴,我可以获得图像 -当我从外部站点调用图像时,它工作正常。 我已启用: define ('AL

我对Timthum的这个版本有以下问题:2.8.10(在Wordpress安装服务器Ubuntu上运行):

-当我从托管网站的服务器调用图像时,我遇到了以下错误:

发生了一个错误 发生以下错误:

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

如果我在浏览器中复制/粘贴,我可以获得图像

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

define ('ALLOW_ALL_EXTERNAL_SITES', TRUE);

在第33行。

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

这就是我让timthumb使用multisite所做的工作。您需要将此代码添加到主题的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="" />
/includes/timtumb.php?q=100&w=180&h=200&zc=1&a=t&src=“alt=”“/>
其中postImage是保存图像URL的元字段的名称


祝您愉快。

我刚刚解决了这个问题,在我的例子中,这个问题与文件路径中有一个平铺有关

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


HTH!

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

在functions.php中更改

}

}

注:唯一的实际修改发生在第3行(粗体):
$theImageSrc=strstr(wp\u get\u attachment\u url(get\u post\u缩略图\u id($post\u id)),“/wp content”)

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

我必须在
timtumb config.php中添加正确的一个

define('LOCAL_FILE_BASE_DIRECTORY', "/home/www/mysite/");

这两个步骤对我有效:

  • 设置为true允许所有外部站点,第33行:
if(!defined('ALLOW_ALL_EXTERNAL_SITES'))define('ALLOW_ALL_EXTERNAL_SITES',TRUE);

  • 注释行~212
/$this->src=preg\u replace('/https?:\/\/(?:www\)?'.$this->myHost'/i','.$this->src);


资料来源:

这很有效,但这真的很愚蠢……为什么timthumb需要这个?
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;
define('LOCAL_FILE_BASE_DIRECTORY', "/home/www/mysite/");