I want to check wether an image has some alt text and show this in the panel (txt or info) of a files field.
So to show the alt field text I can use:
info: {{ file.alt }}
But if it is empty I would like to show a warning text instead of nothing.
I presume this would require an external method but I’m not sure if it should be a custom field or file method?
So I tried using a small plugin called file-methods
with an index.php
of:
<?php
Kirby::plugin('sfi/file-methods', [
'fileMethods' => [
'alt-warn' => function () {
/* Just trying to return some stuff here*/
return $this->file()->filename();
},
]
]);
But using the below does not work.
info: {{ file.alt -warn}}
I’m obviously missing something here and would appreciate any pointers.