Created
December 12, 2016 16:15
-
-
Save mtribone/d6868054b73f77ae5327ca1d1298a92b to your computer and use it in GitHub Desktop.
Overriding the image options set by image_tag helper for accessibility and adding aria-hidden = true.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Render the thumbnail, if available, for a document and | |
# link it to the document record. | |
# | |
# @param [SolrDocument] document | |
# @param [Hash] image_options to pass to the image tag | |
# @param [Hash] url_options to pass to #link_to_document | |
# @return [String] | |
def render_thumbnail_tag(document, image_options = {}, url_options = {}) | |
image_options[:alt] = "" | |
image_options["aria-hidden"] = true | |
value = if blacklight_config.view_config(document_index_view_type).thumbnail_method | |
send(blacklight_config.view_config(document_index_view_type).thumbnail_method, document, image_options) | |
elsif blacklight_config.view_config(document_index_view_type).thumbnail_field | |
url = thumbnail_url(document) | |
image_tag url, image_options if url.present? | |
end | |
if value | |
if url_options == false || url_options[:suppress_link] | |
value | |
else | |
link_to_document document, value, url_options | |
end | |
end | |
end |
Thanks for this. I have been trying to solve the same issue. 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mtribone I would suggest an optional assign (||=) instead of a plain assign (=) on lines 10 and 11 so that you only set those values if the user didn't set them up when they called
render_thumbnail
: