-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Gatsby-image: Placeholder image causes screen readers to read each image twice. #8579
Comments
Because of that fade transition there still will be short timespan where 2 images are visible. Would removing |
@pieh Thank you for the quick reply. Images without Even if you give it empty The only surefire way to ensure the screen reader does not read out one of the images is to add either a style of Would it not be able to time the application of Not the cleanest of solutions I know, but right now these images will cause quite a nasty experience for screen reader users. If this is a no go one could also say that during the |
Just double checked with a colleague. Turns out that setting the Either set |
This was briefly discussed here in ticket 8256, I think setting the alt tag empty is the correct (and most likely easiest solution. |
That will be perfect. Setting the alt attribute to empty for the actual image while loading and then setting the alt attribute of the placeholder to empty when the image is loaded. Switching the actual alt value like this will ensure that anyone who encounters either a loading or loaded picture with a screen reader will get one instance only and get the correct alt value read back to them. |
I have looked over the lib, and I think I have any easy solution using the |
New version |
Description
Because the placeholder image remains visible in the DOM, screen readers will encounter both images and read the image tag, as well as the
alt
text.This means that each image is duplicated for screen reader users.
I am using Gatsby V2 with
gatsby-image
v2.0.9.I tested this behaviour with NVDA in Firefox and iOS VoiceOver in Safari. Both setups read duplicate images.
Steps to reproduce
Add the
Img
fromgatsby-image
and browse the resulting web page with a screen reader.I am not adding any code as this happens for all instances.
Expected result
When navigating the web page with a screen reader, every unique image should only be read out once.
Actual result
Every image is read out twice as the screen reader first encounters the placeholder image and then the actual image.
Suggested fix
This issue can be reliably prevented through the use of
display:none
as elements with this does not get read out by screen readers.Therefore, applying
display:none
to the main image until it is loaded, and then applyingdisplay:none
to the placeholder image.Here is my current workaround for the placeholder image part. I cannot also apply this fix to the main image whilst loading, as the
imgStyle
is applied to the placeholder as well.Environment
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Binaries:
Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
gatsby: ^2.0.0 => 2.0.6
gatsby-image: ^2.0.9 => 2.0.9
gatsby-plugin-manifest: ^2.0.2 => 2.0.2
gatsby-plugin-offline: ^2.0.5 => 2.0.5
gatsby-plugin-react-helmet: ^3.0.0 => 3.0.0
gatsby-plugin-sass: ^2.0.1 => 2.0.1
gatsby-source-datocms: ^2.0.0-alpha.6 => 2.0.0-alpha.6
The text was updated successfully, but these errors were encountered: