forked from AkkomaGang/akkoma
Add a video thumbnail to the OpenGraph metadata if Media Preview Proxy is enabled.
This commit is contained in:
parent
19a49dd757
commit
2cf648d419
1 changed files with 15 additions and 0 deletions
|
@ -96,6 +96,7 @@ defp build_attachments(%{data: %{"attachment" => attachments}}) do
|
|||
| acc
|
||||
]
|
||||
|> maybe_add_dimensions(url)
|
||||
|> maybe_add_video_thumbnail(url)
|
||||
|
||||
_ ->
|
||||
acc
|
||||
|
@ -124,4 +125,18 @@ defp maybe_add_dimensions(metadata, url) do
|
|||
metadata
|
||||
end
|
||||
end
|
||||
|
||||
defp maybe_add_video_thumbnail(url, metadata) do
|
||||
cond do
|
||||
Pleroma.Config.get([:media_preview_proxy, :enabled], false) ->
|
||||
[
|
||||
{:meta, [property: "og:image:width", content: "#{url["width"]}"], []},
|
||||
{:meta, [property: "og:image:height", content: "#{url["height"]}"], []},
|
||||
{:meta, [property: "og:image", content: MediaProxy.preview_url(url["href"])], []}
|
||||
]
|
||||
|
||||
true ->
|
||||
metadata
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue