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): captions do not show fallback based on filename #14219

Merged
merged 5 commits into from
May 23, 2019

Conversation

FrederikBolding
Copy link
Contributor

Description

Fixed an issue where captions would show the image filename if no caption/alt was given.

Related Issues

Fixes #14188

@DSchau DSchau changed the title Fixed an issue where captions would show filename in case of no caption fix(gatsby-remark-images): captions do not show fallback based on filename May 21, 2019
Copy link
Contributor

@DSchau DSchau left a comment

Choose a reason for hiding this comment

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

First of all--thanks for doing this!

Few things:

  1. How about a test to validate the functionality? e.g. creating empty alt text with an image and validating that a caption does not appear?
  2. You had a lint error, I've queued up a job to fix it right up. You may need to pull from your branch, e.g.
git pull origin caption-issues

before making any changes!

@FrederikBolding
Copy link
Contributor Author

Had a chance to fix the linting issues. Will do a test a bit later!

@FrederikBolding
Copy link
Contributor Author

FrederikBolding commented May 21, 2019

@DSchau Added a test!

EDIT: Seems that there's an issue with the jest snapshot? Is it Windows related or something maybe?

@FrederikBolding
Copy link
Contributor Author

@DSchau I just reverted the change to the snapshot - Seems to be working fine now!

Copy link
Contributor

@DSchau DSchau left a comment

Choose a reason for hiding this comment

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

Looks great! One final comment, then let's get this merged. Thanks!

packages/gatsby-remark-images/src/__tests__/index.js Outdated Show resolved Hide resolved
@FrederikBolding
Copy link
Contributor Author

There you go!

@DSchau DSchau self-assigned this May 23, 2019
@DSchau DSchau merged commit 167df1a into gatsbyjs:master May 23, 2019
@DSchau
Copy link
Contributor

DSchau commented May 23, 2019

Successfully published:

@FrederikBolding FrederikBolding deleted the caption-issues branch May 23, 2019 23:10
weakish added a commit to weakish/site that referenced this pull request May 27, 2019
gatsby-remark-images 3.0.11
(introduced in 7de7ad4)
will show alt as caption if no caption is provided,
and filename as caption if no alt/caption is provided.
gatsbyjs/gatsby#14219 fixed the fallback to filename issue,
but still preserves the fallback to alt behaviour.
Thus I set showCaptions to false.
(`alt` is intended for users cannot see the image.
Displaying *alternative* text *alongside* images feels wierd.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[gatsby-remark-images]: bug: uses filename as alt text when showCaptions is true
2 participants