2012-09-14 28 views
3

我有这个版本Timthum以下问题的内部图像:2.8.10(WordPress的安装运行 - 服务器的Ubuntu):Timthumb:找不到指定

- 当我从来电图片服务器托管的网站,我得到这个错误:

一个TimThumb发生错误 以下错误(或多个)发生:

Could not find the internal image you specified. 

查询字符串:SRC = HTTP://my-host.it/ WP-内容/ 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行

回答

0

首先让我知道你在使用WordPress多站点?如果是,那么你不需要编辑任何东西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。

有一个不错的。

1

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

函数。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_t humbnail_id($ post_id)),“/ wp-content”);

+0

这工作,但,这是非常愚蠢的......为什么timthumb需要这个? – Blackbam

1

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

我不得不添加在正确的timthumb-config.php

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

这两步工作对我来说:

  • 设置为真正 ALLOW_ALL_EXTERNAL_SITES,在行〜33:

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

+0

不适用于我 – SISYN