-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix leaking internal config to user-defined
loader
prop in `next/im…
…age` (#36013) The `config` was changed from a global variable to a function parameter of the `loader()` function in PR #33559 as an implementation detail, not as a public API. It was not meant to be used by the end user which is why it was [undocumented](https://nextjs.org/docs/api-reference/next/image#loader). This config is meant for the default Image Optimization API. Since the `loader` prop bypasses the default Image Optimization API in favor of a custom function, that config is no longer be relevant because the function can implement the optimization url however it desires. - Fixes #35115
- Loading branch information
Showing
3 changed files
with
77 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/integration/image-component/basic/pages/loader-prop.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Image from 'next/image' | ||
|
||
const LoaderExample = () => { | ||
return ( | ||
<div> | ||
<p>Custom loader in both next.config.js and loader prop</p> | ||
<Image | ||
id="loader-prop-img" | ||
src="foo.jpg" | ||
width={300} | ||
height={400} | ||
loader={({ config, src, width }) => { | ||
if (config) { | ||
return 'https://example.vercel.sh/error-unexpected-config' | ||
} | ||
return `https://example.vercel.sh/success/${src}?width=${width}` | ||
}} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default LoaderExample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters