-
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
gatsby-plugin-sharp fluid maxWidth maxHeight misleading #12972
Comments
I think that using |
I think you might be misunderstanding the With those width and height parameters you're supposed to be expressing the largest width and height you're going to display the image at, in CSS pixels. But your browser will choose a source image to make use of as many physical pixels as it can. If your display is high resolution (like most current mobile phones, and many current laptops), this will often be an image with a larger resolution than the presentation size you dictated to Gatsby. |
My suggestion is as @missmatsuko said above, to add an option for cropping behaviour: cover or contain (and possibly further options for cover, to control how the cropping happens), and for now to set the default to cover, since it sounds like that's the current behaviour. At the next major version bump, that default can change to contain, which I'd argue is the expected behaviour. |
@tremby I didn't know about physical pixels vs CSS pixels before. This makes a lot more sense now. I agree that the real issue now is the misleading nature of maxHeight and maxWidth and what they do with cropping. I would add that we make it obvious Also add that the |
It's not just maxWidth and maxHeight, it's also srcSetBreakpoints; see https://www.gatsbyjs.org/packages/gatsby-plugin-sharp#fluid for details. |
Sorry I meant for the default, when srcSetBreakPoints is not provided. |
Description
fluid
but not documentedSteps to reproduce
in src/components/image.js, call
fluid
like so:Expected result
Expect maxWidth and maxHeight to control the max image size made by fluid.
Actual result
Environment
Proposal
maxWidth
andmaxHeight
#11851
The text was updated successfully, but these errors were encountered: