Panel thumbnails for uploaded font files

I’m trying to show server generated thumbnails for my uploaded font files.

I generate – via file.create:after – a preview of each font as PNG and save it in the same folder. Filename is in the style of font-name.otf.png and I was hoping for some Kirby-magic to pick this file as a preview and use it as thumbnail. But no.

How can/Can I make a link between the uploaded OTF-file and the generated PNG and see it as the thumbnail in files field/section in the panel?

I’m on Kirby 3.8.3.

If the the name of the font file and the preview are the same, you can get it by filename:

Assuming your are in a loop

<?php foreach ($page->files()->filterBy('extension', 'otf') as $font): ?>
<?php  if ($preview = $page->files()->find($font->filename() . '.png')): ?>
   <img src="<?=$preview->url() ?>" alt="whatever">
<?php endif ?>
<?php endforeach ?>

Hi @texnixe,

Thanks for your quick reply.

I was a bit unclear what I was asking for. I’m looking for showing the thumbnail in the panel, rather than on the website. Replacing the clip-icon in the screenshot below.

Others looking for a solution. With help from Bastian, this is how you can achieve what I was looking to do:

"Let’s say this is your setup

example.otf
example.otf.txt
example.oft.png

In example.otf.txt you could set the template:

Template: font

Then add a blueprint:

site/blueprint/files/font.yaml

And in there set the image options like this:

title: Font File
image:
  query: file.siblings.findBy("name", file.filename)

This should work in theory. "

And works for me!