diff --git a/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php b/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php index e03fbbd81..e12b6a19b 100644 --- a/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php +++ b/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php @@ -9,6 +9,9 @@ namespace Grav\Common\Media\Traits; +use Grav\Common\Page\Medium\MediumFactory; +use Grav\Common\Page\Medium\ThumbnailImageMedium; + /** * Trait VideoMediaTrait * @package Grav\Common\Media\Traits @@ -51,14 +54,27 @@ public function playsinline($status = false) /** * Parsedown element for source display mode * - * @param array $attributes - * @param bool $reset + * @param array $attributes + * @param bool $reset * @return array */ protected function sourceParsedownElement(array $attributes, $reset = true) { $location = $this->url($reset); + if (!isset($attributes['poster']) || ($attributes['poster'] !== 0 && $attributes['poster'] !== '0')) { + if ($this->thumbnailExists('page')) { + $thumb = $this->get("thumbnails.page", false); + if ($thumb) { + $thumb = $thumb instanceof ThumbnailImageMedium ? $thumb : MediumFactory::fromFile($thumb, ['type' => 'thumbnail']); + $attributes['poster'] = $thumb->url(); + } + } + } + if (isset($attributes['poster']) && ($attributes['poster'] === 0 || $attributes['poster'] === '0')) { + unset($attributes['poster']); + } + return [ 'name' => 'video', 'rawHtml' => 'Your browser does not support the video tag.',