-
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
Autogenerate alt text for images #2910
Comments
@KyleAMathews Would this be a difficult task for a newbie to take up? |
Nope! A PR adding this would need
Do you want to take this on? |
Yes I would want to take this up, but I will keep it open for other's as well if I take too much time to get this done. |
Awesome! Let us know your progress! Also don't feel bad about throwing up a partially finished PR. |
Go @vivek12345! 👍 |
Thank you :) |
🙌 Btw. gatsby-remark-copy-linked-files also generates a default alt text for HTML images in Markdown ( gatsby/packages/gatsby-remark-copy-linked-files/src/index.js Lines 121 to 127 in d220fca
AFAIU this mimics what happens to regular Markdown images that do not have an user-defined alt text ( |
Yeah! Let's get this in gatsby-plugin-sharp and then add it like normal to all the usual places. |
When we think about the point of alt text, it's for a11y (screen readers) and SEO (tells googlebot what this is an image of). In order of preference, it's better to have: 1) accurate, hand-typed alt text, then 2) empty string alt "", then 3) no alt text, and finally 4) incorrect alt text. Assuming the above is true, a feature like this could cause issues b/c auto generating alt text from horribly-named images will jump to the fourth option. If this feature gets included then maybe a warning or strong notice to the user that their images should be descriptive would be helpful. Or instead, would it be better to check if an alt text is included and if not, add a warning informing the user that they should include an alt text in their image? |
There is also the SEO factor to consider. The way you would name an image for Google is not (necessarily) the way you would describe an image with alt text. Given that we are only talking about images defined in frontmatter (because it's easy to add alt text to a markdown image), could the alt text be added in the frontmatter where the link to the image is defined and added to the title: Example
slug: example
primaryImage: ./images/example.jpg
primaryImage_alt: Picture of an example
secondaryImage: ./images/secondary.jpg
secondaryImage_alt: Picture of an example |
Cool idea but it'd be in a plugin so closing |
@KyleAMathews I'd definitely argue this should be built and easy to use in for the simple reason that making it easy to use will mean more people will use it, which is better for accessibility. Alt tags play a very important role and should be supported out of the box imho. |
It'd be great for a community member to build. We use issues to track ongoing core work and as this isn't ongoing, I needed to close it. It is a great idea and if it ever becomes something we in core do, then we'll reopen in. Feel free to start a project around it now in your own repo! |
Using an image recognition api for this in a plugin would be killer. |
https://twitter.com/sarah_edo/status/930083568411217920
We could add support for this to gatsby-transformer-sharp so every image includes an alt text.
The text was updated successfully, but these errors were encountered: