Merge branch 'rich-media-ordering' into 'develop'
Rich Media Parser should use first image found Closes #3356 See merge request pleroma/pleroma!4329
This commit is contained in:
commit
a8e863e0d6
6 changed files with 185 additions and 18 deletions
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.Web.RichMedia.Parsers.MetaTagsParser do
|
|||
|> Enum.reduce(data, fn el, acc ->
|
||||
attributes = normalize_attributes(el, prefix, key_name, value_name)
|
||||
|
||||
Map.merge(acc, attributes)
|
||||
Map.merge(attributes, acc)
|
||||
end)
|
||||
|> maybe_put_title(html)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,5 +11,16 @@ defmodule Pleroma.Web.RichMedia.Parsers.TwitterCard do
|
|||
|> MetaTagsParser.parse(html, "og", "property")
|
||||
|> MetaTagsParser.parse(html, "twitter", "name")
|
||||
|> MetaTagsParser.parse(html, "twitter", "property")
|
||||
|> filter_tags()
|
||||
end
|
||||
|
||||
defp filter_tags(tags) do
|
||||
Map.filter(tags, fn {k, _v} ->
|
||||
cond do
|
||||
k in ["card", "description", "image", "title", "ttl", "type", "url"] -> true
|
||||
String.starts_with?(k, "image:") -> true
|
||||
true -> false
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue