mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Image Optimization API currently does not work if a custom loaderFile is specified in next.config.js, even if loader is explicitly set to 'default', because it is currently being overridden to 'custom' simply because a loaderFile is specified. This is unnecessary and causing the Image Optimization API routes not to be initialized since the change to the config happens before the routes are initialized. [Sandbox Reproduction](https://codesandbox.io/p/sandbox/purple-pine-t7hhgl?file=%2Fimage-loader.js%3A8%2C1) - Fixes #53415
36 lines
652 B
JavaScript
36 lines
652 B
JavaScript
import React from 'react'
|
|
import Image from 'next/image'
|
|
|
|
function loader({ src, width, quality }) {
|
|
return `${src}?wid=${width}&qual=${quality || 35}`
|
|
}
|
|
|
|
const Page = () => {
|
|
return (
|
|
<div>
|
|
<h1>Loader Config</h1>
|
|
<Image
|
|
id="img1"
|
|
alt="img1"
|
|
src="/logo.png"
|
|
width="400"
|
|
height="400"
|
|
priority
|
|
/>
|
|
<p>Scroll down...</p>
|
|
<div style={{ height: '100vh' }} />
|
|
<h2>Loader Prop</h2>
|
|
<Image
|
|
id="img2"
|
|
alt="img2"
|
|
src="/logo.png"
|
|
width="200"
|
|
height="200"
|
|
loader={loader}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default Page
|