Replace Kirby hook related to file type with hidden field

This commit is contained in:
Paul Nicoué 2025-05-11 18:09:32 +02:00
parent 03a44a5ec5
commit 6788340d3e
2 changed files with 5 additions and 12 deletions

View file

@ -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 }}"

View file

@ -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 <a href="https://github.com/kirbyzone/sitemapper" target="_blank">Sitemapper by Kirbyzone</a>.'
],
// 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' => [