From 9fbea2df6e5435984473d62de0929c2037eec956 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 5 May 2021 12:37:52 -0500 Subject: Fall back to OEmbed "url" for Photo types --- lib/pleroma/web/rich_media/parser/card.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3