-
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
fix(gatsby-image): When art-directing images, default the padding aspect ratio to first image without a media query when no media query matches #21431
Conversation
This would be really useful - is this going to merge anytime soon? |
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.
nice bug fix! Thanks for finding & fixing
Holy buckets, @mjmaurer — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
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! |
I am using gatsby-image 2.3.4 and unfortunately this does not work for me. When the page is loaded it is still using the aspect ratio of the first source instead of the matched one. I am logging out the Here is a preview link: https://preview.zuckerjagdwurst.com |
Aso having this issue, but only on production builds, on development it works as expected |
@bogdansoare yea, it's only happening in production! |
I have the same issue |
For now the easiest way to fix this is to have 2 gatsby images one for small screens and one for larger, then toggle between the 2 of them with media queries |
Please sub to this issue to be notified of a fix, continue discussion there. |
Description
When art directing multiple images and no media query matches, the current implementation chooses the first image with a media query.
This PR will choose the first image without
media
if no images match currentwindow
. This reflects what one would expect from the documentation (right now the mobile image would never be selected)The documentation reflects what one would expect from mobile-first design.
I don't believe this is a breaking change. Any client that has
media
with every image will continue to work the same way. Any client that has an image withoutmedia
probably expects the behavior that this PR implements.Related Issues
Addresses documentation error mentioned above
Addresses #15189 when adding a "default" image (without media query)
Related to art direction support in #13395