-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: remote srcset images not being resized and deduplication not working in certain cases #8823
Conversation
🦋 Changeset detectedLatest commit: b0444b9 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
// Caution: The logic below is a bit tricky, as we need to make sure we don't generate the same image multiple times | ||
// When making changes, make sure to test with different combinations of local/remote images widths, densities, and dimensions etc. |
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.
Added a "There be dragons" comment here because it's honestly super tricky to completely avoid making transforms that are functionally equivalent to another one, but don't have quite the exact same shape.
Common examples includes:
- A transform where
webp
is specified manually vs one where it's not. Due to the default, both of those results in the same image. - A transform where
width
is specified, but it's equivalent to the width of the image, so it's not resized.
@@ -1,3 +1,4 @@ | |||
import { deterministicString } from 'deterministic-object-hash'; |
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.
I found this package in the backwoods somewhere in a random stack overflow thread, but it's honestly quite nice and does everything I wanted.
!preview srcset-remote |
|
Is there any chance to know when is this gonna get merged? It's a major bug fix on the newly announced feature... I know this issue exists so I won't use |
We'll release it Monday morning CET, it needs to get reviewed and we don't typically do releases on the weekend |
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.
The logic is very complex, I can't really understand it.
Sorry, I tried making it more readable in this PR than the initial code, but it's kinda hard to make neat. Images are complicated 😔 I added a bunch of comments to clarify some parts, in addition to clarifying the points you commented on, hope it helps. |
It's okay, you did a great job! Thank you for addressing my comments. Feel free to merge it whenever you want. I don't have big concerns |
Changes
Continuation of #8819
This PR also reworks completely how we do the transforms for
srcset
, putting special care into avoiding regenerating images when unnecessary. It's possible that there's still some edge cases where it doesn't work, nonetheless as far as I could tell, it does work!This also fixes #8839, since it's in the same area.
Testing
Added tests!
Docs
N/A