commit: 52368e670222c2add5f5677d864dd64c9376c553
parent b6b7de20100e980849404a9e7384617a15df1e43
Author: faried nawaz <faried@gmail.com>
Date: Thu, 18 May 2023 02:17:29 +0500
fix meta tag for twitter cards and image attachments
The name of the tag should be twitter:image, not twitter:player.
Also, add twitter:image:alt meta tags.
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/pleroma/web/metadata/providers/twitter_card.ex b/lib/pleroma/web/metadata/providers/twitter_card.ex
@@ -76,9 +76,11 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
{:meta, [name: "twitter:card", content: "summary_large_image"], []},
{:meta,
[
- name: "twitter:player",
+ name: "twitter:image",
content: MediaProxy.url(url["href"])
- ], []}
+ ], []},
+ {:meta, [property: "twitter:image:alt", content: truncate(attachment["name"])],
+ []}
| acc
]
|> maybe_add_dimensions(url)
@@ -130,4 +132,10 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
metadata
end
end
+
+ defp truncate(text) do
+ # truncate to 420 characters
+ # see https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup
+ Pleroma.Formatter.truncate(text, 420)
+ end
end