Browse Source

bug fix for webp support, add svg image support

master
filesite 3 months ago
parent
commit
cf1b6ce701
  1. 6
      conf/app.php
  2. 4
      lib/DirScanner.php
  3. 21
      themes/beauty/controller/ListController.php
  4. 6
      themes/beauty/controller/SiteController.php
  5. 2
      www/css/beauty.css

6
conf/app.php

@ -3,7 +3,7 @@
* Config * Config
*/ */
$configs = array( $configs = array(
'version' => '0.2.3', 'version' => '0.2.4',
'releaseDate' => '2024-9-7', 'releaseDate' => '2024-9-7',
'showVersion' => false, //默认不显示版本号和发布日期 'showVersion' => false, //默认不显示版本号和发布日期
@ -49,10 +49,10 @@ $configs = array(
'googleimage' => array( 'googleimage' => array(
'imageHeight' => 350, //图片高度,单位:px 'imageHeight' => 350, //图片高度,单位:px
'contact' => 'FileSite图片网站订制联系:<a href="https://filesite.io" target="_blank">FileSite.io</a>', 'contact' => 'FileSite图片网站订制联系:<a href="https://filesite.io" target="_blank">FileSite.io</a>',
'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif'), 'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif', 'svg'),
), ),
'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif'), 'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif', 'svg'),
'supportedVideoExts' => array('mp4', 'mov', 'm3u8'), 'supportedVideoExts' => array('mp4', 'mov', 'm3u8'),
'screenshot_start' => 1000, //视频播放页快照截取开始时间,单位:毫秒 'screenshot_start' => 1000, //视频播放页快照截取开始时间,单位:毫秒
'screenshot_expire_seconds' => 315360000, //视频封面图缓存3650天 'screenshot_expire_seconds' => 315360000, //视频封面图缓存3650天

4
lib/DirScanner.php

@ -43,6 +43,7 @@ Class DirScanner {
'jpeg', //图片 'jpeg', //图片
'png', //图片 'png', //图片
'webp', //图片 'webp', //图片
'svg', //图片
'gif', //图片 'gif', //图片
'ico', //图标 'ico', //图标
'mp3', //音乐 'mp3', //音乐
@ -398,6 +399,7 @@ Class DirScanner {
'jpeg' => "{$webRoot}{$directory}{$filename}.{$extension}", 'jpeg' => "{$webRoot}{$directory}{$filename}.{$extension}",
'png' => "{$webRoot}{$directory}{$filename}.{$extension}", 'png' => "{$webRoot}{$directory}{$filename}.{$extension}",
'webp' => "{$webRoot}{$directory}{$filename}.{$extension}", 'webp' => "{$webRoot}{$directory}{$filename}.{$extension}",
'svg' => "{$webRoot}{$directory}{$filename}.{$extension}",
'gif' => "{$webRoot}{$directory}{$filename}.{$extension}", 'gif' => "{$webRoot}{$directory}{$filename}.{$extension}",
'ico' => "{$webRoot}{$directory}{$filename}.{$extension}", 'ico' => "{$webRoot}{$directory}{$filename}.{$extension}",
'mp3' => "{$webRoot}{$directory}{$filename}.{$extension}", 'mp3' => "{$webRoot}{$directory}{$filename}.{$extension}",
@ -809,7 +811,7 @@ Class DirScanner {
} }
//获取目录下第一个图片作为封面图返回 //获取目录下第一个图片作为封面图返回
public function getSnapshotImage($realpath, $imgExts = array('jpg', 'jpeg', 'png', 'webp', 'gif')) { public function getSnapshotImage($realpath, $imgExts = array('jpg', 'jpeg', 'png', 'webp', 'gif', 'svg')) {
$iterator = new RecursiveIteratorIterator( $iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($realpath, RecursiveDirectoryIterator::SKIP_DOTS), new RecursiveDirectoryIterator($realpath, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST RecursiveIteratorIterator::SELF_FIRST

21
themes/beauty/controller/ListController.php

@ -30,12 +30,12 @@ Class ListController extends Controller {
return $this->redirect('/'); return $this->redirect('/');
} }
$currentDir = $cachedParentData[$cateId]; if (strpos($cacheParentDataId, $cateId) === false && empty($cachedParentData[$cateId])) {
if (strpos($cacheParentDataId, $cateId) === false && empty($currentDir)) {
throw new Exception("缓存数据中找不到当前目录,请返回上一页重新进入!", 404); throw new Exception("缓存数据中找不到当前目录,请返回上一页重新进入!", 404);
}else if (strpos($cacheParentDataId, $cateId) !== false) { }else if (strpos($cacheParentDataId, $cateId) !== false) { //为播放页面查询当前目录下所有视频
$currentDir = $cachedParentData; $currentDir = $cachedParentData;
} }else if (!empty($cachedParentData)) {
$currentDir = $cachedParentData[$cateId];
//密码授权检查 //密码授权检查
$isAllowed = Common::isUserAllowedToDir($currentDir['directory']); $isAllowed = Common::isUserAllowedToDir($currentDir['directory']);
@ -44,8 +44,11 @@ Class ListController extends Controller {
return $this->redirect($goUrl); return $this->redirect($goUrl);
} }
//扫描当前目录
$scanner->setWebRoot($this->getCurrentWebroot($currentDir['realpath'])); $scanner->setWebRoot($this->getCurrentWebroot($currentDir['realpath']));
$scanner->setRootDir($currentDir['realpath']); $scanner->setRootDir($currentDir['realpath']);
}
//优先从缓存读取数据 //优先从缓存读取数据
$maxScanDeep = 0; //最大扫描目录级数 $maxScanDeep = 0; //最大扫描目录级数
@ -130,10 +133,6 @@ Class ListController extends Controller {
}); });
} }
//获取目录面包屑
$subcate = !empty($scanResults[$cateId]) ? $scanResults[$cateId] : array();
$breadcrumbs = $this->getBreadcrumbs($currentDir, $cachedParentData, $scanner);
//获取当前目录下的readme //获取当前目录下的readme
$cateReadmeFile = $scanner->getDefaultReadme(); $cateReadmeFile = $scanner->getDefaultReadme();
if (!empty($cateReadmeFile)) { if (!empty($cateReadmeFile)) {
@ -149,6 +148,8 @@ Class ListController extends Controller {
$expireSeconds = 86400; $expireSeconds = 86400;
$mp3File = Common::getCacheFromFile($cacheKey, $expireSeconds); $mp3File = Common::getCacheFromFile($cacheKey, $expireSeconds);
//当前目录数据
$subcate = !empty($scanResults[$cateId]) ? $scanResults[$cateId] : array();
//翻页支持 //翻页支持
$page = $this->get('page', 1); $page = $this->get('page', 1);
@ -221,6 +222,10 @@ Class ListController extends Controller {
} }
//获取目录面包屑
$breadcrumbs = $this->getBreadcrumbs($currentDir, $cachedParentData, $scanner);
$viewName = '//site/index'; //共享视图 $viewName = '//site/index'; //共享视图
$params = compact( $params = compact(
'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme', 'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme',

6
themes/beauty/controller/SiteController.php

@ -433,14 +433,12 @@ Class SiteController extends Controller {
$imgSource = imagecreatefromgif($img_filepath); $imgSource = imagecreatefromgif($img_filepath);
break; break;
case '.webp': case '.webp':
//php >= 5.4 if (function_exists('imagecreatefromwebp')) {
if (phpversion() >= 5.4) {
$imgSource = imagecreatefromwebp($img_filepath); $imgSource = imagecreatefromwebp($img_filepath);
} }
break; break;
case '.bmp': case '.bmp':
//php >= 7.2 if (function_exists('imagecreatefrombmp')) {
if (phpversion() >= 7.2) {
$imgSource = imagecreatefrombmp($img_filepath); $imgSource = imagecreatefrombmp($img_filepath);
} }
break; break;

2
www/css/beauty.css

@ -82,7 +82,7 @@ a:link{text-decoration:none}
.im_item>a{overflow: hidden;display:block;position:relative;width: 100%;height: 100%} .im_item>a{overflow: hidden;display:block;position:relative;width: 100%;height: 100%}
.im_img_title{background:rgba(7, 7, 7, .1);position:absolute;left:0;right:0;bottom:0;top:0;color:#EEE;border-radius:10px} .im_img_title{background:rgba(7, 7, 7, .1);position:absolute;left:0;right:0;bottom:0;top:0;color:#EEE;border-radius:10px}
.im_img_title .folder_title{position:absolute;bottom:10px;left:10px;margin-right:10px;font-weight:bold;padding:3px;border:solid 1px #444;border-radius:6px;font-size:13px;background-color:#333;opacity:0.7} .im_img_title .folder_title{position:absolute;bottom:10px;left:10px;margin-right:10px;font-weight:bold;padding:3px;border:solid 1px #444;border-radius:6px;font-size:13px;background-color:#333;opacity:0.7}
.im_img_title .right-bottom{left:auto;right:5px;bottom:5px;margin-right:0;padding:0 2px;font-size:11px;border:0 none;font-weight:300;color:#CCC} .im_img_title .right-bottom{padding-left:5px;font-size:11px;border:0 none;font-weight:300;color:#CCC}
.im_img_title img{vertical-align:bottom} .im_img_title img{vertical-align:bottom}
.im_item:hover .im_img{transform:scale(1.03)} .im_item:hover .im_img{transform:scale(1.03)}
.im_item:hover .im_img_title,.im_item:hover .im_img_title .right-bottom{color:#FFF} .im_item:hover .im_img_title,.im_item:hover .im_img_title .right-bottom{color:#FFF}

Loading…
Cancel
Save