mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Merge branch 'restore/card-img-alt' into 'develop'
Include image description in status media cards See merge request pleroma/pleroma!4108
This commit is contained in:
commit
6cfb0d7ddb
4 changed files with 27 additions and 4 deletions
1
changelog.d/card-image-description.add
Normal file
1
changelog.d/card-image-description.add
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Include image description in status media cards
|
|
@ -58,6 +58,10 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
|
||||||
format: :uri,
|
format: :uri,
|
||||||
description: "Preview thumbnail"
|
description: "Preview thumbnail"
|
||||||
},
|
},
|
||||||
|
image_description: %Schema{
|
||||||
|
type: :string,
|
||||||
|
description: "Alternate text that describes what is in the thumbnail"
|
||||||
|
},
|
||||||
title: %Schema{type: :string, description: "Title of linked resource"},
|
title: %Schema{type: :string, description: "Title of linked resource"},
|
||||||
description: %Schema{type: :string, description: "Description of preview"}
|
description: %Schema{type: :string, description: "Description of preview"}
|
||||||
}
|
}
|
||||||
|
|
|
@ -583,6 +583,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
provider_url: page_url_data.scheme <> "://" <> page_url_data.host,
|
provider_url: page_url_data.scheme <> "://" <> page_url_data.host,
|
||||||
url: page_url,
|
url: page_url,
|
||||||
image: image_url,
|
image: image_url,
|
||||||
|
image_description: rich_media["image:alt"] || "",
|
||||||
title: rich_media["title"] || "",
|
title: rich_media["title"] || "",
|
||||||
description: rich_media["description"] || "",
|
description: rich_media["description"] || "",
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
|
|
|
@ -738,7 +738,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
||||||
{:ok, card} =
|
{:ok, card} =
|
||||||
Card.create(page_url, %{image: page_url <> "/example.jpg", title: "Example website"})
|
Card.create(page_url, %{image: page_url <> "/example.jpg", title: "Example website"})
|
||||||
|
|
||||||
%{provider_name: "example.com"} = StatusView.render("card.json", card)
|
assert match?(%{provider_name: "example.com"}, StatusView.render("card.json", card))
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a rich media card without a site name or image renders correctly" do
|
test "a rich media card without a site name or image renders correctly" do
|
||||||
|
@ -751,7 +751,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
||||||
|
|
||||||
{:ok, card} = Card.create(page_url, fields)
|
{:ok, card} = Card.create(page_url, fields)
|
||||||
|
|
||||||
%{provider_name: "example.com"} = StatusView.render("card.json", card)
|
assert match?(%{provider_name: "example.com"}, StatusView.render("card.json", card))
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a rich media card without an image renders correctly" do
|
test "a rich media card without an image renders correctly" do
|
||||||
|
@ -765,7 +765,24 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
||||||
|
|
||||||
{:ok, card} = Card.create(page_url, fields)
|
{:ok, card} = Card.create(page_url, fields)
|
||||||
|
|
||||||
%{provider_name: "example.com"} = StatusView.render("card.json", card)
|
assert match?(%{provider_name: "example.com"}, StatusView.render("card.json", card))
|
||||||
|
end
|
||||||
|
|
||||||
|
test "a rich media card without descriptions returns the fields with empty strings" do
|
||||||
|
page_url = "https://example.com"
|
||||||
|
|
||||||
|
fields = %{
|
||||||
|
"url" => page_url,
|
||||||
|
"site_name" => "Example site name",
|
||||||
|
"title" => "Example website"
|
||||||
|
}
|
||||||
|
|
||||||
|
{:ok, card} = Card.create(page_url, fields)
|
||||||
|
|
||||||
|
assert match?(
|
||||||
|
%{description: "", image_description: ""},
|
||||||
|
StatusView.render("card.json", card)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a rich media card with all relevant data renders correctly" do
|
test "a rich media card with all relevant data renders correctly" do
|
||||||
|
@ -781,7 +798,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
||||||
|
|
||||||
{:ok, card} = Card.create(page_url, fields)
|
{:ok, card} = Card.create(page_url, fields)
|
||||||
|
|
||||||
%{provider_name: "example.com"} = StatusView.render("card.json", card)
|
assert match?(%{provider_name: "example.com"}, StatusView.render("card.json", card))
|
||||||
end
|
end
|
||||||
|
|
||||||
test "a rich media card has all media proxied" do
|
test "a rich media card has all media proxied" do
|
||||||
|
|
Loading…
Reference in a new issue