Skip to content
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

fix(gatsby-remark-images): update to accept alt as title when no title present #13489

Merged
merged 6 commits into from
Apr 19, 2019
Merged

fix(gatsby-remark-images): update to accept alt as title when no title present #13489

merged 6 commits into from
Apr 19, 2019

Conversation

jamessimone
Copy link
Contributor

Description

Some image sources only allow the setting of the alt image attribute when creating images in markdown. An example of this is Dropbox Paper. It would be nice to use the alt as the title for the image when no title is present and the showCaptions config value is enabled.

Related Issues

Fixes #13448

Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jamessimone and congratulations on your first contribution to Gatsby! Enjoy the swag 😉

@sidharthachatterjee
Copy link
Contributor

Went ahead and cleaned up some code I noticed after approving! Hope you don't mind @jamessimone 🙂

@jamessimone
Copy link
Contributor Author

@sidharthachatterjee not at all! Thank you for making this even better 😄

@sidharthachatterjee sidharthachatterjee changed the title (gatsby-remark-images) Update to accept alt as title when no title present fix(gatsby-remark-images): update to accept alt as title when no title present Apr 19, 2019
@sidharthachatterjee sidharthachatterjee self-requested a review April 19, 2019 12:42
Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the snapshots, it looks like we introduced a bug where title (used in other places) is always being set to alt as opposed to only the showCaption case!

Also maybe a good time to add tests for the showCaption behaviour

@jamessimone
Copy link
Contributor Author

@sidharthachatterjee I went to add a test for this, but I wanted to ask first if there is a way to only run the tests for gatsby-remark-images. When I ran yarn jest packages/gatsby-remark-images/src/ I got the following error: Cannot find module 'gatsby-plugin-sharp' from 'index.js'

I saw that plugin-sharp is listed as a peer dependency to the project but perhaps the tests can only be run from the root gatsby level due to that? Just wanted to ensure I wasn't doing something wrong there. Thank you to you and @pieh for jumping on this!

@pieh
Copy link
Contributor

pieh commented Apr 19, 2019

@jamessimone Sid had exact same issue with jest. I'm not sure why both of you have this issue and I don't ...

But to move things forward - I added some basic tests for showCaptions to not block the PR because of those jest problems.

@pieh pieh added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Apr 19, 2019
@sidharthachatterjee sidharthachatterjee merged commit 80c7023 into gatsbyjs:master Apr 19, 2019
@gatsbot
Copy link

gatsbot bot commented Apr 19, 2019

Holy buckets, @jamessimone — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (Currently we’ve got a couple t-shirts available, plus some socks that are really razzing our berries right now.)
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

@sidharthachatterjee
Copy link
Contributor

Thank you so much @jamessimone and @pieh 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gatsby-remark-images not show captions in md file
3 participants