From 3ae90b42e0c0642e3f26dff3271e52072d105adf Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 24 Jul 2024 08:24:17 +0800 Subject: [PATCH] fix warning --- themes/beauty/controller/ListController.php | 8 ++++---- themes/beauty/controller/SiteController.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/beauty/controller/ListController.php b/themes/beauty/controller/ListController.php index 7c41feb..5898330 100644 --- a/themes/beauty/controller/ListController.php +++ b/themes/beauty/controller/ListController.php @@ -108,12 +108,12 @@ Class ListController extends Controller { if ($showType == 'image' && !empty($scanResults[$cateId]['files'])) { $scanResults[$cateId]['files'] = array_filter($scanResults[$cateId]['files'], function($item) { $imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif'); - return in_array($item['extension'], $imgExts); + return !empty($item['extension']) && in_array($item['extension'], $imgExts); }); }else if ($showType == 'video' && !empty($scanResults[$cateId]['files'])) { $scanResults[$cateId]['files'] = array_filter($scanResults[$cateId]['files'], function($item) { $videoExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8'); - return in_array($item['extension'], $videoExts); + return !empty($item['extension']) && in_array($item['extension'], $videoExts); }); } @@ -166,7 +166,7 @@ Class ListController extends Controller { break; } - if (in_array($item['extension'], $imgExts)) { + if (!empty($item['extension']) && in_array($item['extension'], $imgExts)) { array_push($imgs, $item); $index ++; } @@ -186,7 +186,7 @@ Class ListController extends Controller { break; } - if (in_array($item['extension'], $videoExts)) { + if (!empty($item['extension']) && in_array($item['extension'], $videoExts)) { array_push($videos, $item); $index ++; } diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index 5cb434f..ab13afb 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -145,12 +145,12 @@ Class SiteController extends Controller { if ($showType == 'image') { $scanResults = array_filter($scanResults, function($item) { $imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif'); - return in_array($item['extension'], $imgExts); + return !empty($item['extension']) && in_array($item['extension'], $imgExts); }); }else if ($showType == 'video') { $scanResults = array_filter($scanResults, function($item) { $videoExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8'); - return in_array($item['extension'], $videoExts); + return !empty($item['extension']) && in_array($item['extension'], $videoExts); }); } @@ -170,7 +170,7 @@ Class SiteController extends Controller { break; } - if (in_array($item['extension'], $imgExts)) { + if (!empty($item['extension']) && in_array($item['extension'], $imgExts)) { array_push($imgs, $item); $index ++; } @@ -189,7 +189,7 @@ Class SiteController extends Controller { break; } - if (in_array($item['extension'], $videoExts)) { + if (!empty($item['extension']) && in_array($item['extension'], $videoExts)) { array_push($videos, $item); $index ++; }