diff --git a/app/Helpers/aggro_helper.php b/app/Helpers/aggro_helper.php index 4a519a00..c0ea834c 100644 --- a/app/Helpers/aggro_helper.php +++ b/app/Helpers/aggro_helper.php @@ -119,7 +119,7 @@ function clean_feed_cache() */ function clean_thumbnail($videoid) { - $path = ROOTPATH . 'public/thumbs/' . $videoid . '.jpg'; + $path = ROOTPATH . 'public/thumbs/' . $videoid . 'webp'; if (file_exists($path)) { unlink($path); } @@ -208,7 +208,7 @@ function fetch_feed($feed, $spoof, $cache = 1800) function fetch_thumbnail($videoid, $thumbnail) { helper('aggro'); - $path = ROOTPATH . 'public/thumbs/' . $videoid . '.jpg'; + $path = ROOTPATH . 'public/thumbs/' . $videoid . '.webp'; $buffer = fetch_url($thumbnail); if (! empty($buffer)) { @@ -219,6 +219,7 @@ function fetch_thumbnail($videoid, $thumbnail) Config\Services::image() ->withFile($path) ->resize(600, 338, false, 'width') + ->convert(IMAGETYPE_WEBP) ->save($path, 40); return true; diff --git a/app/Models/AggroModels.php b/app/Models/AggroModels.php index 3ed7208e..8d8c7453 100644 --- a/app/Models/AggroModels.php +++ b/app/Models/AggroModels.php @@ -82,7 +82,7 @@ public function checkThumbs() $thumbs = $query->getResult(); foreach ($thumbs as $thumb) { - $path = ROOTPATH . 'public/thumbs/' . $thumb->video_id . '.jpg'; + $path = ROOTPATH . 'public/thumbs/' . $thumb->video_id . '.webp'; if (! file_exists($path)) { $message = $thumb->video_id . ' missing thumbnail'; @@ -129,7 +129,7 @@ public function checkVideo($videoid) public function cleanThumbs() { $utilityModel = new UtilityModels(); - $thumbs = ROOTPATH . 'public/thumbs/*.jpg'; + $thumbs = ROOTPATH . 'public/thumbs/*.webp'; $files = glob($thumbs); $now = time(); diff --git a/app/Views/videos.php b/app/Views/videos.php index 227eb452..d3b76dad 100644 --- a/app/Views/videos.php +++ b/app/Views/videos.php @@ -18,7 +18,7 @@
diff --git a/public/.htaccess b/public/.htaccess index 38c47281..cc05933e 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,6 +1,10 @@ # Disable directory browsing Options All -Indexes +# Add webp and avif image format support +AddType image/webp .webp +AddType image/avif .avif + # ---------------------------------------------------------------------- # Rewrite engine # ---------------------------------------------------------------------- diff --git a/public/placeholder.jpg b/public/placeholder.jpg deleted file mode 100644 index 0cc96e39..00000000 Binary files a/public/placeholder.jpg and /dev/null differ diff --git a/public/placeholder.webp b/public/placeholder.webp new file mode 100644 index 00000000..285541b0 Binary files /dev/null and b/public/placeholder.webp differ diff --git a/public/thumbs/.htaccess b/public/thumbs/.htaccess index 12a23aa4..75ae7086 100644 --- a/public/thumbs/.htaccess +++ b/public/thumbs/.htaccess @@ -3,5 +3,5 @@ RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^.*(\.gif|\.jpe?g|\.png)$ /placeholder.jpg [L] + RewriteRule ^.*(\.jpe?g|\.png|\.webp)$ /placeholder.webp [L]