Video (mp4) preview in panel

If you auto-generate such a poster image from the video, you can give it the same name as the video file. Then you can solve this with a file method

Example files section:

test:
  type: files
  layout: cards
  template: video
  image:
    query: file.videoposter
    cover: true

File method defined in plugin:

<?php

Kirby::plugin('texnixe/methods', [
    'fileMethods' => [
        'videoposter' => function() {
            $filename = $this->name() . '.jpg';
            if($poster = $this->parent()->image($filename)) {
                return $poster;
            } else {
                return null;
            }
        }
    ]
]);

For extracting a poster from the video, you can use a file.upload:after in combination with the PHP-FFMpeg library.

1 Like