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

feat(gatsby-remark-images): Add flag to suppress css background-image to prevent FOUB #17154

Merged
merged 17 commits into from
Sep 10, 2019
Merged

feat(gatsby-remark-images): Add flag to suppress css background-image to prevent FOUB #17154

merged 17 commits into from
Sep 10, 2019

Conversation

kimbaudi
Copy link
Contributor

Description

This PR makes changes to gatsby-plugin-sharp and gatsby-remark-images in order to address issue #16516.

I created a new option for gatsby-remark-images plugin called disableBgImageOnAlpha which is disabled by default. When disableBgImageOnAlpha is enabled (i.e., set to true), it will check the image file for opacity/transparency. If the image contains transparency, then the background-image css property is disabled on <span class="gatsby-resp-image-background-image"></span>, which will prevent the "flash of ugly blur-up" (FOUB).

The reason why I made changes to gatsby-plugin-sharp is to expose stats, which is how I determine whether the image contains transparency.

Related Issues

Fixes #16516

@kimbaudi kimbaudi requested a review from a team as a code owner August 28, 2019 18:45
@kimbaudi kimbaudi requested review from ajschmidt8 and chasemccoy and removed request for ajschmidt8, chasemccoy and gabefromutah August 28, 2019 18:52
@lannonbr lannonbr changed the title feat: gatsby-remark-images - add flag to suppress css background-image to prevent FOUB feat(gatsby-remark-images): Add flag to suppress css background-image to prevent FOUB Aug 28, 2019
@kimbaudi kimbaudi requested a review from a team as a code owner August 29, 2019 00:02
@lannonbr lannonbr added the topic: media Related to gatsby-plugin-image, or general image/media processing topics label Sep 3, 2019
…y-remark-images-add-flag-to-disable-bg-img-on-images-w-transparency
…y-remark-images-add-flag-to-disable-bg-img-on-images-w-transparency
@kimbaudi kimbaudi requested a review from a team as a code owner September 7, 2019 00:29
…y-remark-images-add-flag-to-disable-bg-img-on-images-w-transparency
…y-remark-images-add-flag-to-disable-bg-img-on-images-w-transparency
…y-remark-images-add-flag-to-disable-bg-img-on-images-w-transparency
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

This looks good! Thanks for taking this on. I've added a few nits.

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

kimbaudi commented Sep 9, 2019

Thanks for the code review. I've made the necessary changes.

@wardpeet
Copy link
Contributor

ok sweet, thanks. Doing a quick test and I'll merge right after! Thank you for doing this and for your patience.

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

It works and you'll have to enable it to take effect so 👍. thank you for your time!

@wardpeet wardpeet merged commit 125fd01 into gatsbyjs:master Sep 10, 2019
@kimbaudi kimbaudi deleted the topics/gatsby-remark-images-add-flag-to-disable-bg-img-on-images-w-transparency branch September 10, 2019 19:16
@kimbaudi
Copy link
Contributor Author

kimbaudi commented Sep 11, 2019

@wardpeet - Although this PR got merged into master and gatsby-remark-images doc shows the new disableBgImageOnAlpha option, this PR is not available. Seems like some checks haven't completed (125fd01). I just want to know if you are aware of this. Hopefully, all check will be completed soon 😄

@kimbaudi
Copy link
Contributor Author

I just confirmed that this PR got merged into master 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: media Related to gatsby-plugin-image, or general image/media processing topics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gatsby-remark-images: disable background-image on gatsby-resp-image-background-image to prevent FOUB
3 participants