logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 8b390d27dce0c1827ed4c8c959612b6126624c9a
parent a1af122499d3558d9fa6d5606c394e01f36e95e4
Author: faried nawaz <faried@gmail.com>
Date:   Thu, 18 May 2023 03:20:44 +0500

twitter card: handle case where image has no alt text

Diffstat:

Mlib/pleroma/web/metadata/providers/twitter_card.ex5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/pleroma/web/metadata/providers/twitter_card.ex b/lib/pleroma/web/metadata/providers/twitter_card.ex @@ -79,8 +79,7 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do name: "twitter:image", content: MediaProxy.url(url["href"]) ], []}, - {:meta, [property: "twitter:image:alt", content: truncate(attachment["name"])], - []} + {:meta, [name: "twitter:image:alt", content: truncate(attachment["name"])], []} | acc ] |> maybe_add_dimensions(url) @@ -133,6 +132,8 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do end end + defp truncate(nil), do: "" + defp truncate(text) do # truncate to 420 characters # see https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup