From d7adf4bec71c765196b9b28a8f609a20aa34c070 Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 17 Jul 2024 09:22:13 +0800 Subject: [PATCH] show small image for dir snapshot --- themes/beauty/controller/SiteController.php | 10 ++++++++++ themes/beauty/views/site/index.php | 16 ++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index ce8dfb0..1b44fec 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -213,6 +213,16 @@ Class SiteController extends Controller { } }else { $url = $imgFile['path']; + + //小尺寸图片支持 + $cacheKey = $this->getCacheKey($imgFile['id'], 'imgsm'); + $expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 + $cacheSubDir = 'image'; + $cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); + if (!empty($cachedData)) { + $url = $cachedData; + } + Common::saveCacheToFile($cacheKey, $url); } }else { diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index 08cb707..6b264c9 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -177,15 +177,15 @@ eof; } if (in_array($first_img['extension'], $imgExts)) { - if ($index > 0) { - echo << -eof; - } else { - echo << + $imgUrl = urlencode($first_img['path']); + $smallUrl = "/site/smallimg/?id={$first_img['id']}&url={$imgUrl}"; + echo << eof; - } } else { echo <<