Allow images to fall back to unoptimized state when URL does not match remotePatterns #64226
art-alexeyenko
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
Current next image approach is very uncompromising: either an optimized image is rendered or the image is missing if it doesn't match remotePatterns. In case of editing site layout adding an image can sometime lead to empty display.
One alternative is to specify a very lax remote pattern which defeats the purpose a bit.
Another is to basically copy nextjs's pattern matching logic and dynamically apply "unoptimized" when image src does not match patterns. It would be best for nextjs to have the option to do this dynamic unoptimized fallback out of the box.
Proposal
Add an
unoptimizedFallback
boolean attribute to next image component. When it's enabled and image's src does not match remotePatterns, the image'sunoptimized
attribute will be set to true and image will render as is.PR with possible solution: art-alexeyenko#1 , will post to nextjs repo if feature request is approved.
Beta Was this translation helpful? Give feedback.
All reactions