Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
2cf648d4
Commit
2cf648d4
authored
Jun 09, 2021
by
feld
Browse files
Add a video thumbnail to the OpenGraph metadata if Media Preview Proxy is enabled.
parent
19a49dd7
Pipeline
#36531
failed with stages
in 8 minutes and 22 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/metadata/providers/open_graph.ex
View file @
2cf648d4
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment