Set default filename to page slug for a single file blueprint

Description:
I have created a custom file blueprint fish_cover_image.php that limits uploads to exactly 512 × 256 px images in webp/png/avif format. Now, I want the Kirby Panel’s upload dialog to pre-fill the “Filename” field with the page slug—but only for this one blueprint, not for every single file upload.

Current Behavior:

  • Kirby prompts for a filename, defaulting to “image.jpg” or a random name.
  • I already use a file.create:after hook to rename uploads, but it affects all uploads, and I need it scoped to fish_cover_image only.

What I Need:

  • In the upload dialog, the “Filename” input should default to {{ page.slug() }} only when uploading a file with the fish_cover_image blueprint.

Attempts So Far:

  1. file.create:after hook
    – Works, but is too global (runs on every upload).
  2. Blueprint default setting
    – Kirby currently ignores any default setting in file blueprints for the upload dialog.

Question:
How can I extend or override the page.file.create dialog in Kirby so that it pre-fills the filename with the page slug only for the fish_cover_image blueprint, without relying on a global hook?

You can use conditions inside the hook to only apply to a certain template

did you mean like this?

use Kirby\Cms\File;

return [
    'file.create:after' => function (File $file) {
        // Nur in Seiten mit Template "fish"
        if ($file->page()->intendedTemplate() == 'fish' && $file->template() == 'fish_cover_image') {
            // Neuer Name = Page-Slug, Extension beibehalten
            $new = $file->changeName($file->page()->slug());
            // ALT-Attribut auf den Page-Titel setzen
            $new->update([
                'alt' => $file->page()->title()->value()
            ]);
        }
    }
];