diff --git a/src/elements/Asset.php b/src/elements/Asset.php index acde040fb27..1e27aabe942 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -46,7 +46,6 @@ use craft\events\DefineAssetUrlEvent; use craft\events\GenerateTransformEvent; use craft\fieldlayoutelements\assets\AltField; -use craft\fs\Temp; use craft\helpers\ArrayHelper; use craft\helpers\Assets; use craft\helpers\Cp; @@ -2749,6 +2748,35 @@ public function getPreviewHtml(): string ($userSession->getId() == $this->uploaderId || $userSession->checkPermission("editPeerImages:$volume->uid")) ); + switch ($this->kind) { + case Asset::KIND_VIDEO: + $previewInner = + Html::tag('video', Html::tag('source', '', [ + 'type' => $this->getMimeType(), + 'src' => $this->url, + ]), [ + 'class' => 'preview-thumb', + 'controls' => true, + 'preload' => 'metadata', + ]); + break; + case Asset::KIND_AUDIO: + $previewInner = + Html::tag('audio', Html::tag('source', '', [ + 'src' => $this->url, + 'type' => $this->getMimeType(), + ]), [ + 'controls' => true, + 'preload' => 'metadata', + ]); + break; + default: + $previewInner = + Html::tag('div', $this->getPreviewThumbImg(350, 190), [ + 'class' => 'preview-thumb', + ]); + } + $previewThumbHtml = Html::beginTag('div', [ 'id' => 'thumb-container', @@ -2758,9 +2786,7 @@ public function getPreviewHtml(): string $this->hasCheckeredThumb() ? 'checkered' : null, ]), ]) . - Html::tag('div', $this->getPreviewThumbImg(350, 190), [ - 'class' => 'preview-thumb', - ]) . + $previewInner . Html::endTag('div'); // .preview-thumb-container if ($previewable || $editable) { diff --git a/src/web/assets/cp/src/css/_main.scss b/src/web/assets/cp/src/css/_main.scss index ca814a59ac5..a05eb810814 100644 --- a/src/web/assets/cp/src/css/_main.scss +++ b/src/web/assets/cp/src/css/_main.scss @@ -6589,6 +6589,7 @@ $min2ColWidth: 400px; display: flex; flex-direction: row; align-items: center; + justify-content: center; height: 190px; background-color: var(--gray-900); margin-block: 0 var(--spacing);