From c589530e224b8aa6be8a3f4eac19bb3743fce142 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 21 Apr 2026 07:10:45 -0400 Subject: [PATCH] Add constants to track media player height/width (#38755) --- app/helpers/media_player_helper.rb | 6 ++++++ app/views/media/player.html.haml | 8 ++++---- app/views/statuses/_og_image.html.haml | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 app/helpers/media_player_helper.rb diff --git a/app/helpers/media_player_helper.rb b/app/helpers/media_player_helper.rb new file mode 100644 index 0000000000..8b617164d7 --- /dev/null +++ b/app/helpers/media_player_helper.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +module MediaPlayerHelper + PLAYER_HEIGHT = 380 + PLAYER_WIDTH = 670 +end diff --git a/app/views/media/player.html.haml b/app/views/media/player.html.haml index 39c4ccc18f..b2d2121d15 100644 --- a/app/views/media/player.html.haml +++ b/app/views/media/player.html.haml @@ -14,7 +14,7 @@ detailed: true, editable: true, frameRate: meta.dig('original', 'frame_rate'), - height: 380, + height: MediaPlayerHelper::PLAYER_HEIGHT, inline: true, media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer)].as_json, preview: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.file.url(:small), @@ -25,7 +25,7 @@ - elsif @media_attachment.gifv? = react_component :media_gallery, autoplay: true, - height: 380, + height: MediaPlayerHelper::PLAYER_HEIGHT, media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer).as_json], standalone: true do %video{ autoplay: 'autoplay', muted: 'muted', loop: 'loop' } @@ -38,9 +38,9 @@ duration: meta.dig(:original, :duration), foregroundColor: meta.dig('colors', 'foreground'), fullscreen: true, - height: 380, + height: MediaPlayerHelper::PLAYER_HEIGHT, poster: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.account.avatar_static_url, src: @media_attachment.file.url(:original), - width: 670 do + width: MediaPlayerHelper::PLAYER_WIDTH do %audio{ controls: 'controls' } %source{ src: @media_attachment.file.url(:original) } diff --git a/app/views/statuses/_og_image.html.haml b/app/views/statuses/_og_image.html.haml index 7b6ca915c8..fd5939bd74 100644 --- a/app/views/statuses/_og_image.html.haml +++ b/app/views/statuses/_og_image.html.haml @@ -38,8 +38,8 @@ = opengraph 'twitter:player', player_medium_url(media) = opengraph 'twitter:player:stream', full_asset_url(media.file.url(:original)) = opengraph 'twitter:player:stream:content_type', media.file_content_type - = opengraph 'twitter:player:width', '670' - = opengraph 'twitter:player:height', '380' + = opengraph 'twitter:player:width', MediaPlayerHelper::PLAYER_WIDTH + = opengraph 'twitter:player:height', MediaPlayerHelper::PLAYER_HEIGHT - if player_card = opengraph 'twitter:card', 'player' - else