【问题标题】:Timthumb: Could not find the internal image you specifiedTimthumb:找不到您指定的内部图像
【发布时间】:2012-09-07 18:04:58
【问题描述】:

我在使用此版本的 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 行。

【问题讨论】:

    标签: wordpress timthumb


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

      这两个步骤对我有用:

      • 设置为 true 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

      【讨论】:

        【解决方案3】:

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

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

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

        HTH!

        【讨论】:

          【解决方案4】:

          我在多站点安装 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");

          【讨论】:

          • 这行得通,但这真的很愚蠢……为什么 timthumb 需要这个?
          【解决方案5】:

          首先让我知道您使用的是 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 的元字段的名称。

          玩得开心。

          【讨论】:

            猜你喜欢
            • 2013-06-29
            • 2016-06-29
            • 2019-04-10
            • 2012-11-11
            • 2020-07-23
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多