about summary refs log tree commit diff
path: root/app/views/media/player.html.haml
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2021-05-05 21:16:55 +0200
committerGitHub <noreply@github.com>2021-05-05 21:16:55 +0200
commit351c74459084ccffce1333b57c2af9a6b55cac8d (patch)
tree8f698b8df06426414f1f7917b26465cc4a37e4d5 /app/views/media/player.html.haml
parent059df83d1dcabb27d2e638b4835791bd570ec779 (diff)
Fix error when trying to render component for media without meta (#16112)
Diffstat (limited to 'app/views/media/player.html.haml')
-rw-r--r--app/views/media/player.html.haml7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/views/media/player.html.haml b/app/views/media/player.html.haml
index 95e37bb22..f00c8f040 100644
--- a/app/views/media/player.html.haml
+++ b/app/views/media/player.html.haml
@@ -2,8 +2,11 @@
   = render_initial_state
   = javascript_pack_tag 'public', crossorigin: 'anonymous'
 
+:ruby
+  meta = @media_attachment.file.meta || {}
+
 - if @media_attachment.video?
-  = react_component :video, src: @media_attachment.file.url(:original), preview: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.file.url(:small), frameRate: @media_attachment.file.meta.dig('original', 'frame_rate'), blurhash: @media_attachment.blurhash, width: 670, height: 380, editable: true, detailed: true, inline: true, alt: @media_attachment.description, media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer)].as_json do
+  = react_component :video, src: @media_attachment.file.url(:original), preview: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.file.url(:small), frameRate: meta.dig('original', 'frame_rate'), blurhash: @media_attachment.blurhash, width: 670, height: 380, editable: true, detailed: true, inline: true, alt: @media_attachment.description, media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer)].as_json do
     %video{ controls: 'controls' }
       %source{ src: @media_attachment.file.url(:original) }
 - elsif @media_attachment.gifv?
@@ -11,6 +14,6 @@
     %video{ autoplay: 'autoplay', muted: 'muted', loop: 'loop' }
       %source{ src: @media_attachment.file.url(:original) }
 - elsif @media_attachment.audio?
-  = react_component :audio, src: @media_attachment.file.url(:original), poster: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.account.avatar_static_url, backgroundColor: @media_attachment.file.meta.dig('colors', 'background'), foregroundColor: @media_attachment.file.meta.dig('colors', 'foreground'), accentColor: @media_attachment.file.meta.dig('colors', 'accent'), width: 670, height: 380, fullscreen: true, alt: @media_attachment.description, duration: @media_attachment.file.meta.dig(:original, :duration) do
+  = react_component :audio, src: @media_attachment.file.url(:original), poster: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.account.avatar_static_url, backgroundColor: meta.dig('colors', 'background'), foregroundColor: meta.dig('colors', 'foreground'), accentColor: meta.dig('colors', 'accent'), width: 670, height: 380, fullscreen: true, alt: @media_attachment.description, duration: meta.dig(:original, :duration) do
     %audio{ controls: 'controls' }
       %source{ src: @media_attachment.file.url(:original) }