From 6788340d3ec23878aa119b0fee40a8e5f491b4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Nicou=C3=A9?= Date: Sun, 11 May 2025 18:09:32 +0200 Subject: [PATCH] Replace Kirby hook related to file type with hidden field --- site/blueprints/files/image.yml | 4 ++++ site/config/config.php | 13 +------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/site/blueprints/files/image.yml b/site/blueprints/files/image.yml index 31af4ee..ed10a16 100644 --- a/site/blueprints/files/image.yml +++ b/site/blueprints/files/image.yml @@ -10,3 +10,7 @@ fields: help: en: "Short description displayed if the image can't be loaded (also used by screen readers)." fr: "Courte description affichée si l'image ne peut être chargée (également utilisée par les lecteurs d'écran)." + # Hidden field + file_type: + type: hidden + default: "{{ file.type }}" diff --git a/site/config/config.php b/site/config/config.php index f96de10..255fa81 100644 --- a/site/config/config.php +++ b/site/config/config.php @@ -26,7 +26,7 @@ return [ 'link' => 'pages/media-library', 'current' => function (string $current): bool { // Override default menu entry highlighting $path = Kirby\Cms\App::instance()->path(); - return Str::contains($path, 'pages/media-library'); + return Str::contains($path, 'pages/media-library'); // Link of current menu entry }, ], 'users', @@ -38,17 +38,6 @@ return [ 'intro' => false, 'byLine' => 'Sitemap generated with Sitemapper by Kirbyzone.' ], - // Hooks - 'hooks' => [ - 'file.create:after' => function($file) { - // Populate file_type field with $file->type() method after file creation - if ($file->type()) { - $file->update([ - 'file_type' => $file->type() - ]); - } - } - ], // Thumbnails and srcsets presets 'thumbs' => [ 'srcsets' => [