Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions system/src/Grav/Common/Media/Traits/VideoMediaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' => '<source src="' . $location . '">Your browser does not support the video tag.',
Expand Down