-
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
feat(gatsby-image): Add gatsby-image/withIEPolyfill export with object-fit/position support #12681
feat(gatsby-image): Add gatsby-image/withIEPolyfill export with object-fit/position support #12681
Conversation
Update fork with upstream changes
this is great! |
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.
Looks great 💪
I updated the code a bit to accept an external ref as well. I'm going to test this that it doesn't break anything and get this merged tomorrow! 🎉 Thanks for all the hard work. |
Love it! Thanks for the improvements. 👍 |
pushed the latest fix, ref handling is ugly but changing forwardRef inside gatsby-image would be a breaking change. |
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.
Let's ship this when tests pass!
Sounds great! Thanks for guiding it over the finish line. |
Awesome to see this merged in! 🎉 Is it possible to append the docs for gatsby-image about this new feature if it hasn't already? @ooloth |
Add instructions for using `gatsby-image/withIEPolyfill` as implemented by #12681.
Absolutely! I just submitted PR #12869, which adds instructions to the Feel free to improve it as needed. |
* Update README.md Add instructions for using `gatsby-image/withIEPolyfill` as implemented by #12681. * Update packages/gatsby-image/README.md Prompt the user to include an alt attribute, even if empty, for accessibility. Co-Authored-By: ooloth <[email protected]> * Add line breaks Trying to guess what issues Prettier is seeing while my computer is away for repairs... * chore: format
* Update README.md Add instructions for using `gatsby-image/withIEPolyfill` as implemented by gatsbyjs#12681. * Update packages/gatsby-image/README.md Prompt the user to include an alt attribute, even if empty, for accessibility. Co-Authored-By: ooloth <[email protected]> * Add line breaks Trying to guess what issues Prettier is seeing while my computer is away for repairs... * chore: format
Description
This PR will allow users who want
object-fit/object-position
support in IE to simplyimport Img from "gatsby-image/withIEPolyfill"
instead of importing directly from"gatsby-image"
.Please feel free to review the PR and let me know if the implementation can be improved.
The
/withIEPolyfill
version ofgatsby-image
currently does the following:object-fit/position
CSS properties.a. If yes, no polyfill is loaded.
b. If no, the
object-fit-images
polyfill is imported and called.gatsby-image
in a component that passes the newobjectFit
andobjectPosition
prop values to the polyfill implementation (which requires a weirdfont-family
hack).New props
To make the implementation simple, I've added new
objectFit
andobjectPosition
props that will need to be used to pass the corresponding values to the polyfill. This is to avoid a scenario where a user attempts to set these values in a way we can't pass to the polyfill (e.g. via an external CSS stylesheet) and doesn't understand why the polyfill isn't working. Let me know if this API can be improved.Loading polyfill in /withIEPolyfill/index.js
I opted to load the
object-fit-images
polyfill directly inwithIEPolyfill/index.js
rather than ingatsby-browser.js
. If anyone knows of a better way to approach this, please let me know and feel free to make improvements.Polyfill repo has been archived
I was surprised to see that the
object-fit-images
repo has recently been archived by its owner. It still works, but if anyone is concerned about this or knows of a reliable alternative polyfill, please let me know.Docs to be updated once implementation is finalized
Once we've settled on the API for this
/withIEPolyfills
component, a brief explanation will need to be added to thegatsby-image
docs. I held off on adding one for now in case we end up changing the API.Related Issues
Fixes #4021.