diff options
-rw-r--r-- | lib/pleroma/web/rich_media/parser/card.ex | 6 |
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 |