From 31b92b16ed0c42fa2a0de765b28d4e600ff8ac3c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 5 Mar 2024 21:25:00 +0000 Subject: [PATCH] Reduce the height of portrait videos --- src/Model/Item.php | 9 +++++++++ view/templates/video_top.tpl | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 6fba99853b..b5e31f0fba 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3643,6 +3643,13 @@ class Item } if ($PostMedia->mimetype->type == 'video') { + if (($PostMedia->height ?? 0) > ($PostMedia->width ?? 0)) { + $height = min(DI::config()->get('system', 'max_video_height'), $PostMedia->height); + $width = 'auto'; + } else { + $height = 'auto'; + $width = '100%'; + } /// @todo Move the template to /content as well $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('video_top.tpl'), [ '$video' => [ @@ -3651,6 +3658,8 @@ class Item 'name' => $PostMedia->name ?: $PostMedia->url, 'preview' => $preview_url, 'mime' => (string)$PostMedia->mimetype, + 'height' => $height, + 'width' => $width, ], ]); if (($item['post-type'] ?? null) == Item::PT_VIDEO) { diff --git a/view/templates/video_top.tpl b/view/templates/video_top.tpl index 3f9d5886a5..b3cf049e71 100644 --- a/view/templates/video_top.tpl +++ b/view/templates/video_top.tpl @@ -1,6 +1,6 @@
{{* set preloading to none to lessen the load on the server *}} -