I haven’t tested k4 yet.
But maybe You could use a hook to trigger the thumb generation after file upload/ replace.
Something I’d do in a k3 plugin (not tested, just to get the idea):
use Kirby\Cms\App;
use Kirby\Cms\Exception;
Kirby::plugin('k-community/auto-thumb-or-whatever', [
'hooks' => [
'file.create:after' => fn($file) => $file->autoThumb(),
'file.replace:after' => fn($newFile, $oldFile) => $newFile->autoThumb()
],
'fileMethods' => [
'autoThumb' => function() {
$kirby = App::instance();
if($this->isResizable()) {
try {
$kirby->thumb($this->root(), $this->root(), 'myPreset');
// Immediately generate a file in the media folder.
$this->publish();
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
}
]
]);