twitter card: handle case where image has no alt text
This commit is contained in:
parent
a1af122499
commit
8b390d27dc
@ -79,8 +79,7 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
|
|||||||
name: "twitter:image",
|
name: "twitter:image",
|
||||||
content: MediaProxy.url(url["href"])
|
content: MediaProxy.url(url["href"])
|
||||||
], []},
|
], []},
|
||||||
{:meta, [property: "twitter:image:alt", content: truncate(attachment["name"])],
|
{:meta, [name: "twitter:image:alt", content: truncate(attachment["name"])], []}
|
||||||
[]}
|
|
||||||
| acc
|
| acc
|
||||||
]
|
]
|
||||||
|> maybe_add_dimensions(url)
|
|> maybe_add_dimensions(url)
|
||||||
@ -133,6 +132,8 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp truncate(nil), do: ""
|
||||||
|
|
||||||
defp truncate(text) do
|
defp truncate(text) do
|
||||||
# truncate to 420 characters
|
# truncate to 420 characters
|
||||||
# see https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup
|
# see https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup
|
||||||
|
Loading…
Reference in New Issue
Block a user