summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-06-08 15:59:55 -0500
committerMark Felder <feld@feld.me>2021-06-08 15:59:55 -0500
commit5de65ce3e89ba2f229170ed18933c99e5caa8dff (patch)
treea1aa57f95d9017ca81048dc213bf06eeb7059951 /lib
parent1175023687aa7ce33f6b1ee90acb932cfbd58025 (diff)
Set the correct height/width if the data is available when generating twittercard metadata
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/metadata/providers/twitter_card.ex7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/pleroma/web/metadata/providers/twitter_card.ex b/lib/pleroma/web/metadata/providers/twitter_card.ex
index 12c372d77..e28f832d4 100644
--- a/lib/pleroma/web/metadata/providers/twitter_card.ex
+++ b/lib/pleroma/web/metadata/providers/twitter_card.ex
@@ -80,11 +80,14 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
# TODO: Need the true width and height values here or Twitter renders an iFrame with
# a bad aspect ratio
"video" ->
+ height = url["height"] || 480
+ width = url["width"] || 480
+
[
{:meta, [property: "twitter:card", content: "player"], []},
{:meta, [property: "twitter:player", content: player_url(id)], []},
- {:meta, [property: "twitter:player:width", content: "480"], []},
- {:meta, [property: "twitter:player:height", content: "480"], []},
+ {:meta, [property: "twitter:player:width", content: "#{width}"], []},
+ {:meta, [property: "twitter:player:height", content: "#{height}"], []},
{:meta, [property: "twitter:player:stream", content: url["href"]], []},
{:meta,
[property: "twitter:player:stream:content_type", content: url["mediaType"]], []}