Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when legacy prop detected on
next/image
(#42102)
Instead of hard error, we can try to convert legacy props to the new props and print a warning. We still recommend upgrading by running one (or both) codemods because the new component no longer has a wrapping `<span>`. <img width="616" alt="image" src="https://user-images.githubusercontent.com/229881/198756393-7d981686-f4db-485b-9f5f-1ff614d35959.png"> Read more: https://nextjs.org/docs/messages/next-image-upgrade-to-13
- Loading branch information
Showing
10 changed files
with
171 additions
and
176 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
26 changes: 26 additions & 0 deletions
26
test/integration/next-image-new/default/pages/legacy-layout-fill.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,26 @@ | ||
import Image from 'next/image' | ||
|
||
export default function Page() { | ||
return ( | ||
<div className="page"> | ||
<h1>Using legacy prop layout="fill"</h1> | ||
<p> | ||
Even though we don't support "layout" in next/image, we can try to | ||
correct the style and print a warning. | ||
</p> | ||
<div style={{ position: 'relative', width: '200px', height: '400px' }}> | ||
<Image | ||
id="img" | ||
layout="fill" | ||
src="/test.jpg" | ||
alt="my fill image" | ||
quality={50} | ||
objectFit="cover" | ||
objectPosition="10% 10%" | ||
sizes="200px" | ||
priority | ||
/> | ||
</div> | ||
</div> | ||
) | ||
} |
22 changes: 22 additions & 0 deletions
22
test/integration/next-image-new/default/pages/legacy-layout-responsive.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,22 @@ | ||
import Image from 'next/image' | ||
|
||
export default function Page() { | ||
return ( | ||
<div className="page"> | ||
<h1>Using legacy prop layout="responsive"</h1> | ||
<p> | ||
Even though we don't support "layout" in next/image, we can try to | ||
correct the style and print a warning. | ||
</p> | ||
<Image | ||
id="img" | ||
layout="responsive" | ||
src="/test.png" | ||
width="100" | ||
height="100" | ||
alt="my responsive image" | ||
priority | ||
/> | ||
</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
14 changes: 0 additions & 14 deletions
14
test/integration/next-image-new/invalid-layout/pages/index.js
This file was deleted.
Oops, something went wrong.
Binary file not shown.
66 changes: 0 additions & 66 deletions
66
test/integration/next-image-new/invalid-layout/test/index.test.ts
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
test/integration/next-image-new/invalid-objectfit/pages/index.js
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.