The following code works, but it would be reassuring if someone could confirm it is okay.
I’d like to be able to add a poster image to videos (that will be displayed before the video starts).
In my Blueprint I have a field to upload the poster image:
fields:
poster:
label: Poster for video
type: files
Then in my snippet I have the following:
<video autoplay controls loop poster="<?php echo ( $poster = $file->poster()->toFile() ) ? $poster->url() : ''; ?>" class="border">
<source src="<?= $file->url() ?>">
</video>
<?php if ($file->caption()->isNotEmpty()): ?>
<p class="caption"><?= $file->caption() ?></p>
<?php endif ?>