From 8b2fc81b8dea4bdf9fd746f798c6099476d2f7d2 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 7 Oct 2024 20:48:44 +0900 Subject: [PATCH] Fix #2405 use video thumbnail as SEO image --- classes/display/HTMLDisplayHandler.php | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php index ad1ab48c2..52e5f697d 100644 --- a/classes/display/HTMLDisplayHandler.php +++ b/classes/display/HTMLDisplayHandler.php @@ -573,19 +573,32 @@ class HTMLDisplayHandler foreach ($document_files as $file) { - if ($file->isvalid !== 'Y' || !preg_match('/\.(?:bmp|gif|jpe?g|png|webp)$/i', $file->uploaded_filename)) + if ($file->isvalid !== 'Y' || !preg_match('/\.(?:bmp|gif|jpe?g|png|webp|mp4)$/i', $file->uploaded_filename)) { continue; } - list($width, $height) = @getimagesize($file->uploaded_filename); - if ($width < 100 && $height < 100) + if (str_starts_with($file->mime_type, 'video/')) { - continue; + if ($file->thumbnail_filename) + { + list($width, $height) = @getimagesize($file->thumbnail_filename); + if ($width >= 100 || $height >= 100) + { + $document_images[] = array('filepath' => $file->thumbnail_filename, 'width' => $width, 'height' => $height); + break; + } + } + } + else + { + list($width, $height) = @getimagesize($file->uploaded_filename); + if ($width >= 100 || $height >= 100) + { + $document_images[] = array('filepath' => $file->uploaded_filename, 'width' => $width, 'height' => $height); + break; + } } - - $document_images[] = array('filepath' => $file->uploaded_filename, 'width' => $width, 'height' => $height); - break; } } Rhymix\Framework\Cache::set("seo:document_images:$document_srl", $document_images);