-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ALT to imageOutput/plotOutput #2494
Conversation
Optional parameter to add "alt" attribute to img-tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to put the alt
argument on plotOutput
and imageOutput
, given that the alt text is not dynamic. Then it also does not need to be added to renderPlot
, renderCachedPlot
and renderImage
.
But in
|
Yes, this would require adding data to the div and then on the JavaScript side, adding the |
I'm having problems resolving the JS-checks. I did run Another problem (on Windows 10) is that the build process errors with this message:
I have to manually insert the version and then run build. |
@wch I'd like to add that I was working on some wrapper functions to apply dynamic alt text on the server side and came across this issue and PR. I routinely get requests from people for dynamic alt text in Shiny apps. The static option is a bare minimum, but I think it makes more sense and is more critical to expose this attribute in the Technically, dynamic alt text can be achieved directly with
Something like an |
Ideas of things we could support...
@leonawicz @olyerickson Are there any other tag attributes that should also be dynamic? (Or only just |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting Changes to block merging. The idea is good, but we should look to take more dynamic arguments from within renderPlot
.
It might still be good to have the ...
passed through in the plotOutput
and imageOutput
, but know that they could be overwritten by the result of a renderPlot
execution.
// Set optional alt-attribute | ||
var alttext = $el.attr("alt"); | ||
if (alttext && alttext !== "") { | ||
img.setAttribute("alt", alttext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since alt
exists, let's remove it from $el
. (The alt
attribute is only allowed for img
tags)
As I understand it, ultimately plots are embedded as
For details on acceptable "grouping" of UPDATE: I see you are already are looking at the PSU guidelines; thanks! |
The other suggestions seem good to me if I understand correctly. |
I was wondering if you were working on a separate PR for dynamic alt text. If so, please kindly make a PR for review when you are ready. |
@jooyoungseo My suggestion to accommodate server-side dynamic control rather than a static text option is still relevant, but no I am not working on this or other related PR. |
Thanks very much for your response, @leonawicz. @trafficonese, if you don't mind, I will do the rest of the house-cleaning stuff. |
Having recently read this thread in relation to improving the accessibility of my team's Shiny apps, we've published the following article on Medium: Alt text for dynamic plots in Shiny in case it is useful to the discussion. It uses the technique @leonawicz mentions regarding observers and plot ids. |
@jooyoungseo @itsozz A colleague and I also have a package we've been working on here and there called shinyaccess. We haven't been able to work on it for a while but please feel free to check it out. While I would love for this package to grow to offer as much accessibility and inclusive design as may be possible, I think what would be best for the community in the end is for something like this to be largely redundant with respect to a future version of the shiny package; perhaps for this to become an "opinionated design/alternative collection of Shiny widgets" package. But for now we just want to add as much accessibility features and considerations that we find lacking in the base shiny package. Maybe it's not feasible in the near term for the shiny package to accommodate everything in terms of accessibility on its own, given things like backward compatibility requirements etc., I really don't know. |
Thanks very much for the great work, @leonawicz. Ideally, we want to make Shiny accessible itself, and I have been working on each widget for accessibility. Some widgets need to be patched and tweaked around. For example, we have just made |
@leonawicz, I'll have a look at shinyaccess as soon as I can, thanks for letting me know. Sounds like a very useful package. @jooyoungseo, great to hear about the accessibility improvements being made to Shiny, thanks for the update. I briefly mentioned the contrast and font size issues with |
Yes, it would be greatly appreciated if you could add a comment to the PR. |
I am closing this PR in favor of another follow-up PR (#3006). Thank you very much everyone for all the great input. |
Optional parameter to add alt attribute to img-tag in
renderPlot
andrenderCachedPlot
.closes #612
Shiny-App to Test it