Commit 5de65ce3 authored by feld's avatar feld
Browse files

Set the correct height/width if the data is available when generating twittercard metadata

parent 11750236
Pipeline #36492 passed with stages
in 12 minutes and 13 seconds
......@@ -80,11 +80,14 @@ defp build_attachments(id, %{data: %{"attachment" => attachments}}) 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"]], []}
......
......@@ -123,7 +123,12 @@ test "it renders supported types of attachments and skips unknown types" do
},
%{
"url" => [
%{"mediaType" => "video/webm", "href" => "https://pleroma.gov/about/juche.webm"}
%{
"mediaType" => "video/webm",
"href" => "https://pleroma.gov/about/juche.webm",
"height" => 600,
"width" => 800
}
]
}
]
......@@ -143,8 +148,8 @@ test "it renders supported types of attachments and skips unknown types" do
property: "twitter:player",
content: Router.Helpers.o_status_url(Endpoint, :notice_player, activity.id)
], []},
{:meta, [property: "twitter:player:width", content: "480"], []},
{:meta, [property: "twitter:player:height", content: "480"], []},
{:meta, [property: "twitter:player:width", content: "800"], []},
{:meta, [property: "twitter:player:height", content: "600"], []},
{:meta,
[
property: "twitter:player:stream",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment