diff --git a/controller/CommandController.php b/controller/CommandController.php index 4f3810b..1de6544 100644 --- a/controller/CommandController.php +++ b/controller/CommandController.php @@ -35,6 +35,12 @@ eof; throw new Exception("缺少key参数!", 403); } + //val数据格式转换 + if ($param_value === 'false') { + $param_value = false; + }else if ($param_value === 'true') { + $param_value = true; + } $config_file = __DIR__ . "/../runtime/custom_config.json"; if (file_exists($config_file)) { diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index fc73dea..069fc63 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -185,6 +185,13 @@ Class SiteController extends Controller { $cacheSubDir = 'dir'; $cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); + //如果关闭缩略图 + if (empty(FSC::$app['config']['enableSmallImage']) || FSC::$app['config']['enableSmallImage'] === 'false') { + if (!empty($cachedData) && !empty($cachedData['size']) && $cachedData['size'] == 'small') { + $cachedData = null; + } + } + if (empty($cachedData)) { //从缓存数据中获取目录的realpath $cachedData = Common::getCacheFromFile($cacheId); @@ -218,19 +225,23 @@ Class SiteController extends Controller { }else { $url = $imgFile['path']; $img_id = $imgFile['id']; + $size = 'orignal'; //小尺寸图片支持 - $cacheKey_smimg = $this->getCacheKey($imgFile['id'], 'imgsm'); - $expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 - $cacheSubDir = 'image'; - $cachedData = Common::getCacheFromFile($cacheKey_smimg, $expireSeconds, $cacheSubDir); - if (!empty($cachedData)) { - $url = $cachedData; - $img_id = ''; //无需再次生成小尺寸图片 + if (!empty(FSC::$app['config']['enableSmallImage']) && FSC::$app['config']['enableSmallImage'] !== 'false') { + $cacheKey_smimg = $this->getCacheKey($imgFile['id'], 'imgsm'); + $expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 + $cacheSubDir = 'image'; + $cachedData = Common::getCacheFromFile($cacheKey_smimg, $expireSeconds, $cacheSubDir); + if (!empty($cachedData)) { + $url = $cachedData; + $img_id = ''; //无需再次生成小尺寸图片 + $size = 'small'; + } } $cacheSubDir = 'dir'; - Common::saveCacheToFile($cacheKey, compact('url', 'img_id'), $cacheSubDir); + Common::saveCacheToFile($cacheKey, compact('url', 'img_id', 'size'), $cacheSubDir); } }else { $code = 0; @@ -259,7 +270,13 @@ Class SiteController extends Controller { $cacheKey = $this->getCacheKey($cateId, 'snap'); $img_id = ''; //为保持数据格式一致,图片id传空 $cacheSubDir = 'dir'; - $saved = Common::saveCacheToFile($cacheKey, compact('url', 'img_id'), $cacheSubDir); + + $size = 'orignal'; + if (!empty(FSC::$app['config']['enableSmallImage']) && FSC::$app['config']['enableSmallImage'] !== 'false') { + $size = 'small'; + } + + $saved = Common::saveCacheToFile($cacheKey, compact('url', 'img_id', 'size'), $cacheSubDir); if ($saved !== false) { $code = 1; @@ -314,7 +331,8 @@ Class SiteController extends Controller { $cacheKey = $this->getCacheKey($cateId, 'snap'); $img_id = ''; //为保持数据格式一致,图片id传空 $cacheSubDir = 'dir'; - Common::saveCacheToFile($cacheKey, array('url' => $imgData, 'img_id' => $img_id), $cacheSubDir); + $size = 'small'; + Common::saveCacheToFile($cacheKey, array('url' => $imgData, 'img_id' => $img_id, 'size' => $size), $cacheSubDir); } $cacheKey = $this->getCacheKey($imgId, 'imgsm'); diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index f9690bb..88280b4 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -189,6 +189,9 @@ eof; if (in_array($first_img['extension'], $imgExts)) { $imgUrl = urlencode($first_img['path']); $smallUrl = "/site/smallimg/?id={$first_img['id']}&url={$imgUrl}"; + if (empty(FSC::$app['config']['enableSmallImage']) || FSC::$app['config']['enableSmallImage'] === 'false') { + $smallUrl = $first_img['path']; + } echo <<