-
Notifications
You must be signed in to change notification settings - Fork 26k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: next.config.js with
unstable_getImgProps()
(#52153)
- Fixes #52116
- Loading branch information
Showing
7 changed files
with
150 additions
and
34 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
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
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
34 changes: 34 additions & 0 deletions
34
test/integration/next-image-new/loader-config/pages/get-img-props.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,34 @@ | ||
import { unstable_getImgProps as getImgProps } from 'next/image' | ||
|
||
function loader({ src, width, quality }) { | ||
return `${src}?wid=${width}&qual=${quality || 35}` | ||
} | ||
|
||
export default function Page() { | ||
const { props: img1 } = getImgProps({ | ||
id: 'img1', | ||
alt: 'img1', | ||
src: '/logo.png', | ||
width: '400', | ||
height: '400', | ||
priority: true, | ||
}) | ||
const { props: img2 } = getImgProps({ | ||
id: 'img2', | ||
alt: 'img2', | ||
src: '/logo.png', | ||
width: '200', | ||
height: '200', | ||
loader, | ||
}) | ||
return ( | ||
<div> | ||
<h1>Loader Config</h1> | ||
<img {...img1} /> | ||
<p>Scroll down...</p> | ||
<div style={{ height: '100vh' }} /> | ||
<h2>Loader Prop</h2> | ||
<img {...img2} /> | ||
</div> | ||
) | ||
} |
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
47 changes: 47 additions & 0 deletions
47
test/integration/next-image-new/unoptimized/pages/get-img-props.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,47 @@ | ||
import React from 'react' | ||
import { unstable_getImgProps as getImgProps } from 'next/image' | ||
import testJpg from '../public/test.jpg' | ||
|
||
const Page = () => { | ||
const { props: img1 } = getImgProps({ | ||
id: 'internal-image', | ||
src: '/test.png', | ||
width: 400, | ||
height: 400, | ||
}) | ||
const { props: img2 } = getImgProps({ | ||
id: 'static-image', | ||
src: testJpg, | ||
width: 400, | ||
height: 400, | ||
}) | ||
const { props: img3 } = getImgProps({ | ||
id: 'external-image', | ||
src: 'https://image-optimization-test.vercel.app/test.jpg', | ||
width: 400, | ||
height: 400, | ||
}) | ||
const { props: img4 } = getImgProps({ | ||
id: 'eager-image', | ||
src: '/test.webp', | ||
width: 400, | ||
height: 400, | ||
loading: 'eager', | ||
}) | ||
return ( | ||
<div> | ||
<h1>Unoptimized Config</h1> | ||
<p>Scroll down...</p> | ||
<div style={{ height: '1000vh' }} /> | ||
<img {...img1} /> | ||
<br /> | ||
<img {...img2} /> | ||
<br /> | ||
<img {...img3} /> | ||
<div style={{ height: '1000vh' }} /> | ||
<img {...img4} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
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