Browse Source

show small image for dir snapshot

master
filesite 5 months ago
parent
commit
d7adf4bec7
  1. 10
      themes/beauty/controller/SiteController.php
  2. 16
      themes/beauty/views/site/index.php

10
themes/beauty/controller/SiteController.php

@ -213,6 +213,16 @@ Class SiteController extends Controller {
} }
}else { }else {
$url = $imgFile['path']; $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); Common::saveCacheToFile($cacheKey, $url);
} }
}else { }else {

16
themes/beauty/views/site/index.php

@ -177,15 +177,15 @@ eof;
} }
if (in_array($first_img['extension'], $imgExts)) { if (in_array($first_img['extension'], $imgExts)) {
if ($index > 0) { $imgUrl = urlencode($first_img['path']);
echo <<<eof $smallUrl = "/site/smallimg/?id={$first_img['id']}&url={$imgUrl}";
<img src="/img/beauty/lazy.svg" data-original="{$first_img['path']}" class="bor_radius im_img lazy" alt="{$first_img['filename']}"> echo <<<eof
eof; <img src="/img/beauty/lazy.svg"
} else { data-id="{$first_img['id']}"
echo <<<eof data-original="{$smallUrl}"
<img src="{$first_img['path']}" class="bor_radius im_img" alt="{$first_img['filename']}"> data-original_="{$first_img['path']}"
class="bor_radius im_img lazy" alt="{$first_img['filename']}">
eof; eof;
}
} else { } else {
echo <<<eof echo <<<eof
<img src="/img/default.png" class="bor_radius im_img" alt="default image"> <img src="/img/default.png" class="bor_radius im_img" alt="default image">

Loading…
Cancel
Save