Skip to content

Commit

Permalink
Add alt text to thumbnails (#1078)
Browse files Browse the repository at this point in the history
* Add alt text to thumbnails

* Add text to alt description

* Distinguish alt text from link text
  • Loading branch information
lfarrell authored Feb 21, 2024
1 parent 0a97451 commit 564a035
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/views/catalog/_thumbnail_list_collection.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%# [hyc-override] https://github.com/samvera/hyrax/blob/hyrax-v4.0.0/app/views/catalog/_thumbnail_list_collection.html.erb %>
<%# [hyc-override] Add alt text for thumbnails @todo can be removed when fixed upstream %>
<div class="col-md-3">
<%= document_presenter(document)&.thumbnail&.thumbnail_tag({ alt: "Thumbnail for #{document.title_or_label}" }, { suppress_link: true }) %>
</div>
12 changes: 12 additions & 0 deletions app/views/catalog/_thumbnail_list_default.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%# [hyc-override] https://github.com/samvera/hyrax/blob/hyrax-v4.0.0/app/views/catalog/_thumbnail_list_default.html.erb %>
<%# [hyc-override] Add alt text for thumbnails @todo can be removed when fixed upstream %>
<% model = document.hydra_model %>
<div class="col-md-3">
<% if model == Hyrax::PcdmCollection || model < Hyrax::PcdmCollection %>
<%= document_presenter(document)&.thumbnail&.thumbnail_tag({ alt: "Thumbnail for #{document.title_or_label}"}, suppress_link: true) %>
<% else %>
<div class="list-thumbnail">
<%= document_presenter(document)&.thumbnail&.thumbnail_tag({ alt: "Thumbnail for #{document.title_or_label }" }) %>
</div>
<% end %>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%# [hyc-override] https://github.com/samvera/hyrax/tree/hyrax-v4.0.0/app/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb %>
<%# [hyc-override] Add alt text for thumbnails @todo can be removed when fixed upstream %>
<% document = show_document_list_row %>
<% id = document.id %>
<tr id="document_<%= id %>">
Expand All @@ -10,7 +11,7 @@
<td>
<div class="media">
<%= link_to [main_app, document], "class" => "media-left", "aria-hidden" => "true" do %>
<%= document_presenter(document)&.thumbnail&.thumbnail_tag({ class: "d-none d-md-block file_listing_thumbnail" }, { suppress_link: true }) %>
<%= document_presenter(document)&.thumbnail&.thumbnail_tag({ class: "d-none d-md-block file_listing_thumbnail", alt: "Thumbnail for #{document.title_or_label}" }, { suppress_link: true }) %>
<% end %>
<div class="media-body">
<p class="media-heading">
Expand Down
38 changes: 38 additions & 0 deletions app/views/hyrax/admin/admin_sets/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<%# https://github.com/samvera/hyrax/blob/hyrax-v4.0.0/app/views/hyrax/admin/admin_sets/show.html.erb %>
<%# [hyc-override] Add alt text for thumbnails @todo can be removed when fixed upstream %>
<% provide :page_header do %>
<h1><span class="fa fa-sitemap" aria-hidden="true"></span> <%= t('.header') %></h1>
<% end %>

<div class="row">
<div class="col-md-12">
<div class="card">
<%= render 'show_actions', presenter: @presenter %>

<div class="card-body admin-set row">
<div class="col-md-2">
<% if has_thumbnail? @presenter.solr_document %>
<div class="document-thumbnail">
<%= render_thumbnail_tag(@presenter.solr_document, { alt: 'thumbnail' }, { suppress_link: true }) %>
</div>
<% else %>
<span class="fa fa-sitemap collection-icon-search" aria-hidden="true"></span>
<% end %>
</div>
<div class="col-md-10">
<%= render 'collection_description', presenter: @presenter %>
<%= render 'show_descriptions' %>
</div>
</div>

<div class="card-body admin-set-members">
<h3><%= t '.item_list_header' %></h3>
<%= render 'sort_and_per_page', collection: @presenter %>

<%= render_document_index @member_docs %>

<%= render 'paginate' %>
</div>
</div>
</div>
</div>
3 changes: 3 additions & 0 deletions app/views/hyrax/base/_file_manager_thumbnail.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%# https://github.com/samvera/hyrax/blob/hyrax-v4.0.0/app/views/hyrax/base/_file_manager_thumbnail.html.erb %>
<%# [hyc-override] Add alt text for thumbnails @todo can be removed when fixed upstream %>
<%= document_presenter(node)&.thumbnail&.thumbnail_tag({ alt: 'thumbnail', class: 'thumbnail-inner mw-100' }, {}) %>
40 changes: 40 additions & 0 deletions app/views/hyrax/collections/_list_works.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<%# https://github.com/samvera/hyrax/blob/hyrax-v4.0.0/app/views/hyrax/collections/_list_works.html.erb %>
<%# [hyc-override] Add alt text for thumbnails @todo can be removed when fixed upstream %>
<tr id="document_<%= document.id %>">

<td>
<label for="batch_document_<%= document.id %>" class="sr-only"><%= t("hyrax.dashboard.my.sr.batch_checkbox") %></label>
<%= render 'hyrax/batch_select/add_button', document: document %>&nbsp;
</td>

<td>
<div class='media'>
<%= link_to [main_app, document], class: 'media-left', 'aria-hidden' => true do %>
<%= document_presenter(document)&.thumbnail&.thumbnail_tag(
{ alt: "Thumbnail for #{document.title_or_label}", class: 'd-none d-md-block file_listing_thumbnail' }, { suppress_link: true }
) %>
<% end %>

<div class='media-body'>
<div class='media-heading'>

<%= link_to [main_app, document], id: "src_copy_link#{document.id}", class: 'document-title' do %>
<span class="sr-only">
<%= t("hyrax.dashboard.my.sr.show_label") %>
</span>
<%= document.title_or_label %>
<% end %>

<br />
<%= render_collection_links(document) %>

</div>
</div>
</div>
</td>

<td class="date"><%= document.date_uploaded %></td>
<td class='text-center'>
<span class="fa <%= current_user.trophies.where(work_id: document.id).exists? ? 'fa-star highlighted-work' : 'fa-star-o trophy-off' %>" aria-hidden="true"></span></td>
<td><%= render_visibility_link document %></td>
</tr>
44 changes: 44 additions & 0 deletions app/views/hyrax/dashboard/collections/_list_works.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<%# https://github.com/samvera/hyrax/blob/hyrax-v4.0.0/app/views/hyrax/dashboard/collections/_list_works.html.erb %>
<%# [hyc-override] Add alt text for thumbnails @todo can be removed when fixed upstream %>
<tr id="document_<%= document.id %>">

<td>
<label for="batch_document_<%= document.id %>" class="sr-only"><%= t("hyrax.dashboard.my.sr.batch_checkbox") %></label>
<%= render 'hyrax/batch_select/add_button', document: document %>&nbsp;
</td>

<td>
<div class='media'>
<%= link_to [main_app, document], class: 'media-left', 'aria-hidden': true do %>
<%= document_presenter(document)&.thumbnail&.thumbnail_tag(
{ class: 'd-none d-md-block file_listing_thumbnail', alt: "Thumbnail for #{document.title_or_label}" }, { suppress_link: true }
) %>
<% end %>

<div class='media-body'>
<div class='media-heading'>

<%= link_to [main_app, document], id: "src_copy_link#{document.id}", class: 'document-title' do %>
<span class="sr-only">
<%= t("hyrax.dashboard.my.sr.show_label") %>
</span>
<%= document.title_or_label %>
<% end %>

<br />
<%= render_collection_links(document) %>

</div>
</div>
</div>
</td>

<td class="date"><%= document.date_uploaded %></td>
<td class='text-center'>
<span class="fa <%= current_user.trophies.where(work_id: document.id).exists? ? 'fa-star highlighted-work' : 'fa-star-o trophy-off' %>" aria-hidden="true"></span></td>
<td><%= render_visibility_link document %></td>

<td>
<%= render 'work_action_menu', document: document %>
</td>
</tr>

0 comments on commit 564a035

Please sign in to comment.