-
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
Add custom sizes for fluid images #8825
Conversation
…rp/package.json in #8621
options[fixedDimension] * 2, | ||
options[fixedDimension] * 3, | ||
] | ||
: options.customSizes.slice() |
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.
do we need to create copy of array?
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.
Nope. Turns out I was just being overly safe. I'll get rid of it in a future commit :)
Yeah, I think so (if we aren't doing that somewhere already) Also I think we need to do some additional validation if this is provided by user - we need to ensure that values are Not sure here but maybe we need to sort values as well and maybe remove duplicates (not sure on browser specification for that).
I don't love it, but don't have any nice alternative right now. Any arg we are passing would be "custom" - maybe "sizesBreakpoints" or something like that? |
This weekend I have some time and I'll implement the following changes:
|
Some ideas for the name:
What do you think @pieh? |
I think (not 100% sure) that throwing error should show up both in console/terminal and in
I think that naming things is hard ;) we are not passing "sizes" really as an arg - just breakpoints for sizes (this got stuck in my head after I come up with it), |
@pieh Don't know if you'll already be notified of the update to this PR, but I'll ping you just in case :) |
@nikoladev I thinks it's good right now, no further feedback/requests from me - will leave this open for ~1 day to get more feedback from community |
@pieh Any update on additional feedback? |
@nikoladev there were no additional comments, let's merge it - I should merge it long time ago, heh |
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.
Thanks @nikoladev!
🙏 💜 🎉 |
This PR adds support for custom sizes when creating fluid images. The current implementation returns sizes in the following way:
With this PR you have direct control of the sizes you get back by using a new parameter called
customSizes
. See the example for how it works.Example
Query
(For this example
image.jpg
has a width of 1000)Output
Here's
srcSet
in a more readable format:Some questions
Should
maxWidth
automatically be inserted into thecustomSizes
array so that we have a perfect fit? Right now the nearest width tomaxWidth
is selected forsrc
. (In the example above the710w
version is chosen forsrc
.)Is
customSizes
a good name for it?