mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
twitter card: handle case where image has no alt text
This commit is contained in:
parent
a1af122499
commit
8b390d27dc
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue