Fix attachments not working without alt text

This commit is contained in:
Sol Fisher Romanoff 2022-11-28 12:20:50 +02:00
parent ce377a65c5
commit d623882bce
No known key found for this signature in database
GPG key ID: 9D3F2B64F2341B62
3 changed files with 17 additions and 13 deletions

View file

@ -41,4 +41,8 @@ def open_content? do
false
)
end
def get_attachment_name(%{"name" => name}), do: name
def get_attachment_name(_), do: ""
end

View file

@ -1,6 +1,6 @@
<a class="attachment" href="<%= @url %>">
<a class="attachment" href="<%= @url %>" alt=<%= @name %>" title="<%= @name %>">
<%= if @nsfw do %>
<div class="nsfw-banner" alt="<%= @name %>" title="<%= @name %>">
<div class="nsfw-banner">
<div><%= gettext("Hover to show content") %></div>
</div>
<% end %>
@ -10,6 +10,6 @@
<% "video" -> %>
<video class="u-video" src="<%= @url %>" controls="controls"></video>
<% _ -> %>
<img class="u-photo" src="<%= @url %>" alt="<%= @name %>" title="<%= @name %>">
<img class="u-photo" src="<%= @url %>">
<% end %>
</a>

View file

@ -45,17 +45,17 @@
</div>
<%= if @reply_to do %>
<div class="heading-reply-row">
<a class="reply-to-link" href="<%= @reply_to %>">
<a class="reply-to-link" href="<%= @reply_to %>">
<svg class="fa-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M205 34.8c11.5 5.1 19 16.6 19 29.2v64H336c97.2 0 176 78.8 176 176c0 113.3-81.5 163.9-100.2 174.1c-2.5 1.4-5.3 1.9-8.1 1.9c-10.9 0-19.7-8.9-19.7-19.7c0-7.5 4.3-14.4 9.8-19.5c9.4-8.8 22.2-26.4 22.2-56.7c0-53-43-96-96-96H224v64c0 12.6-7.4 24.1-19 29.2s-25 3-34.4-5.4l-160-144C3.9 225.7 0 217.1 0 208s3.9-17.7 10.6-23.8l160-144c9.4-8.5 22.9-10.6 34.4-5.4z"/>
</svg>
<%= gettext("Reply to") %>
</a>
<span class="h-card">
<%= gettext("Reply to") %>
</a>
<span class="h-card">
<a href="<%= (@reply_to_user.uri || @reply_to_user.ap_id) %>" class="u-url mention">
@<%= @reply_to_user.nickname %>
</a>
</span>
</span>
</div>
<% end %>
<%= if @edited_at do %>
@ -65,7 +65,7 @@
<% end %>
</div>
<div class="status-content">
<%= if @title != "" do %>
<%= if @title && @title != "" do %>
<span class="status-summary"><%= raw @title %></span>
<details <%= if open_content?() do %>open<% end %>>
<summary><%= gettext("Show content") %></summary>
@ -74,14 +74,14 @@
<%= raw @content %>
<%= if length(@attachment) > 0 do %>
<div class="attachments">
<%= for %{"name" => name, "url" => [url | _]} <- @attachment do %>
<%= render("_attachment.html", %{name: name, url: url["href"],
mediaType: fetch_media_type(url), nsfw: @sensitive}) %>
<%= for attachment = %{"url" => [url | _]} <- @attachment do %>
<%= render("_attachment.html", %{name: get_attachment_name(attachment),
url: url["href"], mediaType: fetch_media_type(url), nsfw: @sensitive}) %>
<% end %>
</div>
<% end %>
</div>
<%= if @title != "" do %>
<%= if @title && @title != "" do %>
</details>
<% end %>
</div>