2022-08-31 15:02:43 +02:00
|
|
|
<?php
|
|
|
|
use Kirby\Cms\Html;
|
|
|
|
|
|
|
|
/** @var \Kirby\Cms\Block $block */
|
2025-04-21 18:57:21 +02:00
|
|
|
$caption = $block->caption();
|
|
|
|
|
|
|
|
if (
|
|
|
|
$block->location() == 'kirby' &&
|
|
|
|
$video = $block->video()->toFile()
|
|
|
|
) {
|
|
|
|
$url = $video->url();
|
|
|
|
$attrs = array_filter([
|
|
|
|
'autoplay' => $block->autoplay()->toBool(),
|
|
|
|
'controls' => $block->controls()->toBool(),
|
|
|
|
'loop' => $block->loop()->toBool(),
|
|
|
|
'muted' => $block->muted()->toBool() || $block->autoplay()->toBool(),
|
|
|
|
'playsinline' => $block->autoplay()->toBool(),
|
|
|
|
'poster' => $block->poster()->toFile()?->url(),
|
|
|
|
'preload' => $block->preload()->value(),
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
$url = $block->url();
|
|
|
|
}
|
2022-08-31 15:02:43 +02:00
|
|
|
?>
|
2025-04-21 18:57:21 +02:00
|
|
|
<?php if ($video = Html::video($url, [], $attrs ?? [])): ?>
|
2022-06-17 17:51:59 +02:00
|
|
|
<figure>
|
|
|
|
<?= $video ?>
|
2025-04-21 18:57:21 +02:00
|
|
|
<?php if ($caption->isNotEmpty()): ?>
|
|
|
|
<figcaption><?= $caption ?></figcaption>
|
2022-06-17 17:51:59 +02:00
|
|
|
<?php endif ?>
|
|
|
|
</figure>
|
|
|
|
<?php endif ?>
|