From fc51258d405e3fe84cd481a1b9f0943537ef0a3c Mon Sep 17 00:00:00 2001 From: isUnknown Date: Thu, 19 Sep 2024 14:47:46 +0200 Subject: [PATCH] optimize image --- site/config/config.php | 17 +++++++++-------- site/snippets/event-card.php | 4 ++-- site/templates/home.php | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/site/config/config.php b/site/config/config.php index d64e8a2..faa0bf8 100644 --- a/site/config/config.php +++ b/site/config/config.php @@ -13,14 +13,15 @@ return [ 'format' => 'webp' ], 'srcsets' => [ - 'default' => [ - ['width' => 200, 'format' => 'webp'], - ['width' => 400, 'format' => 'webp'], - ['width' => 600, 'format' => 'webp'], - ['width' => 800, 'format' => 'webp'], - ['width' => 1024, 'format' => 'webp'], - ['width' => 1440, 'format' => 'webp'], - ['width' => 2048, 'format' => 'webp'] + 'default' => [200, 400, 600, 800, 1024, 1440, 2048], + 'webp' => [ + '200w' => ['width' => 200 * 1.5, 'format' => 'webp'], + '400w' => ['width' => 400 * 1.5, 'format' => 'webp'], + '600w' => ['width' => 600 * 1.5, 'format' => 'webp'], + '800w' => ['width' => 800 * 1.5, 'format' => 'webp'], + '1024w' => ['width' => 1024 * 1.5, 'format' => 'webp'], + '1440w' => ['width' => 1440 * 1.5, 'format' => 'webp'], + '2048w' => ['width' => 2048 * 1.5, 'format' => 'webp'] ], ], ], diff --git a/site/snippets/event-card.php b/site/snippets/event-card.php index 000474b..f5140e8 100644 --- a/site/snippets/event-card.php +++ b/site/snippets/event-card.php @@ -3,14 +3,14 @@
gallery()->toFiles()->count() > 1): ?> $event->gallery()->toFiles()->first()->thumb(), + 'file' => $event->gallery()->toFiles()->first(), 'class' => 'image-cover', 'size' => (100 / (12 / $span) - 10) ]) ?> gallery()->toFiles()->count() > 1 ? $event->gallery()->toFiles()->nth(1) : $event->gallery()->toFiles()->first(); - snippet('picture', ["file" => $file->thumb(), 'size' => (100 / (12 / $span) - 10), 'alt' => null]); + snippet('picture', ["file" => $file, 'size' => (100 / (12 / $span) - 10), 'alt' => null]); ?>
diff --git a/site/templates/home.php b/site/templates/home.php index b7234a8..9a0bab7 100644 --- a/site/templates/home.php +++ b/site/templates/home.php @@ -9,10 +9,10 @@
heroLinkUrl()->isNotEmpty() == 'true'): ?> - $site->heroImage()->toFile()->thumb(), 'lazy' => false, 'size' => 50]) ?> + $site->heroImage()->toFile(), 'lazy' => false, 'size' => 60]) ?> - $site->heroImage()->toFile()->thumb(), 'lazy' => false, 'size' => 50]) ?> + $site->heroImage()->toFile(), 'lazy' => false, 'size' => 60]) ?>