summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-05-05 12:37:52 -0500
committerAlex Gleason <alex@alexgleason.me>2021-05-05 12:38:43 -0500
commit9fbea2df6e5435984473d62de0929c2037eec956 (patch)
treeeb4f9d152a9c90815c89feaf96465ba6a0a93758
parent0ebf3b3afdfe9f91e24077a81d9534871a076c99 (diff)
Fall back to OEmbed "url" for Photo types
-rw-r--r--lib/pleroma/web/rich_media/parser/card.ex6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/pleroma/web/rich_media/parser/card.ex b/lib/pleroma/web/rich_media/parser/card.ex
index 71b0a5b17..b29db730b 100644
--- a/lib/pleroma/web/rich_media/parser/card.ex
+++ b/lib/pleroma/web/rich_media/parser/card.ex
@@ -40,7 +40,7 @@ defmodule Pleroma.Web.RichMedia.Parser.Card do
html: sanitize_html(oembed["html"]),
width: oembed["width"],
height: oembed["height"],
- image: oembed["thumbnail_url"] |> proxy(),
+ image: get_image(oembed) |> proxy(),
embed_url: oembed["url"] |> proxy()
}
|> validate()
@@ -89,6 +89,10 @@ defmodule Pleroma.Web.RichMedia.Parser.Card do
end
end
+ defp get_image(%{"thumbnail_url" => image}) when is_binary(image) and image != "", do: image
+ defp get_image(%{"type" => "photo", "url" => image}), do: image
+ defp get_image(_), do: ""
+
defp sanitize_html(html) do
with {:ok, html} <- FastSanitize.Sanitizer.scrub(html, Pleroma.HTML.Scrubber.OEmbed),
{:ok, [{"iframe", _, _}]} <- Floki.parse_fragment(html) do