]> git.mxchange.org Git - friendica.git/commitdiff
Reduce the height of portrait videos
authorMichael <heluecht@pirati.ca>
Tue, 5 Mar 2024 21:25:00 +0000 (21:25 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 5 Mar 2024 21:25:00 +0000 (21:25 +0000)
src/Model/Item.php
view/templates/video_top.tpl

index 6fba99853b85149438528e808ac8f984a4bc0c94..b5e31f0fba4f9f2a46c74c5a3409a3edfc10883e 100644 (file)
@@ -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) {
index 3f9d5886a5595f6227fda27c79c3c09e26159acf..b3cf049e717edb67e8889a3dc818e101d8d29c6f 100644 (file)
@@ -1,6 +1,6 @@
 <div class="video-top-wrapper lframe" id="video-top-wrapper-{{$video.id}}">
        {{* set preloading to none to lessen the load on the server *}}
-       <video src="{{$video.src}}" controls {{if $video.preview}}preload="none" poster="{{$video.preview}}" {else}preload="metadata" {{/if}}width="100%" height="auto">
+       <video src="{{$video.src}}" controls {{if $video.preview}}preload="none" poster="{{$video.preview}}" {else}preload="metadata" {{/if}}width="{{$video.width}}" height="{{$video.height}}">
                <a href="{{$video.src}}">{{$video.name}}</a>
        </video>