From 341cf7270938adad74eab79df128fee1d3706607 Mon Sep 17 00:00:00 2001 From: icret Date: Tue, 4 Jan 2022 19:04:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E9=80=A0=E6=80=A7=E7=9A=84=E5=8F=91?= =?UTF-8?q?=E6=98=8E=E4=BA=86=E4=B8=80=E4=B8=AAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/function.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/application/function.php b/application/function.php index 96288b1..00f542d 100755 --- a/application/function.php +++ b/application/function.php @@ -629,15 +629,14 @@ function creat_thumbnail_by_list($imgUrl) { global $config; - // 关闭生成和输出缩略图浏览 + // 关闭缩略图 if ($config['thumbnail'] === 0) { return $imgUrl; } - // 如果是实时生成 - if ($config['thumbnail'] === 1) { - return get_online_thumbnail($imgUrl); - } - + // 实时生成 + if ($config['thumbnail'] === 1) { + return get_online_thumbnail($imgUrl); + } // 将网址图片转换为相对路径 $pathName = str_replace($config['imgurl'], '', $imgUrl); @@ -647,7 +646,6 @@ function creat_thumbnail_by_list($imgUrl) // 如果图像是gif则直接返回网址 if (isAnimatedGif($abPathName)) { - return $imgUrl; } else { @@ -655,20 +653,18 @@ function creat_thumbnail_by_list($imgUrl) $pathName = str_replace($config['path'], '', $pathName); // 将文件的/转换为_ - $pathName = str_replace('/', '_', $pathName); + $imgName = str_replace('/', '_', $pathName); // 缓存文件是否存在 - if (file_exists(APP_ROOT . $config['path'] . 'thumbnails/' . $pathName)) { + if (file_exists(APP_ROOT . $config['path'] . 'thumbnails/' . $imgName)) { // 存在则返回缓存文件 - return $config['imgurl'] . $config['path'] . 'thumbnails/' . $pathName; + return $config['imgurl'] . $config['path'] . 'thumbnails/' . $imgName; } else { - // 创建缓存文件并输出文件链接 + + // 不存在则创建缓存文件并输出文件链接 require_once __DIR__ . '/class.thumb.php'; - // 获取文件名 - $imgName = basename($imgUrl); - - // cache目录的绝对路径 + // thumbnails目录的绝对路径 $cache_path = APP_ROOT . $config['path'] . 'thumbnails/'; // 创建cache目录 @@ -677,7 +673,9 @@ function creat_thumbnail_by_list($imgUrl) } // 缩略图缓存的绝对路径 - $new_imgName = APP_ROOT . $config['path'] . 'thumbnails/' . date('Y_m_d') . '_' . $imgName; + // $imgName 是不带/i/的相对路径 + + $new_imgName = $cache_path . $imgName; // 创建并保存缩略图 Thumb::out($abPathName, $new_imgName, 300, 300);