
Next.js 13 ๋ฒ์ ์์ Image ํ๊ทธ๋ฅผ ์ฌ์ฉํ ๋ ๋ฐ์ํ ์ค๋ฅ. Image ํ๊ทธ์๋ "width" ์์ฑ์ด ํ์ํ๋ฐ, "width" ์์ฑ์ด ์๋ค๋ ๋ด์ฉ์ด ๋ํ๋๋ค.
Next.js 13 ๋ฒ์ ์ Image ํ๊ทธ๋, src, alt, width, height ์์ฑ์ ํ์๋ก ๊ฐ์ ธ์ผ ํ๊ณ , fill ์์ฑ์ ์ฌ์ฉํ ๋๋ง width, height๋ฅผ ์๋ตํ ์ ์๊ธฐ ๋๋ฌธ์, ๊ทธ ์ธ์ ๊ฒฝ์ฐ์๋ width, height ๊ฐ์ ์ง์ ํด ์ฃผ์ด์ผ ํ๋ค. ๋ค๋ฅธ ํ์ ์์ฑ์ด ๋น ์ก์ ๋๋ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค.
const imageStyle = {
width: '80vw',
height: 'auto',
};
...
<Image
src={imgSrc}
alt="img_alt"
width={800}
height={800}
style={imageStyle}
/>
ํ์ง๋ง ์ด๋ px ๋จ์์ number ๊ฐ๋ง ์ง์ ์ด ๊ฐ๋ฅํ๋ฐ, ๋๋ vw ๋จ์๋ฅผ ์ฌ์ฉํ๊ณ ์ถ์๊ธฐ ๋๋ฌธ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค. ์ด ๊ฒฝ์ฐ์๋ style ์์ฑ์ ํจ๊ป ์ง์ ํ์ฌ width, height ์์ฑ๊ฐ ๋ฑ์ ๋ฎ์ด์ธ ์ ์๋ค. width์ height ๊ฐ์ ์ ๋นํ ์ง์ ํด์ฃผ๊ณ , style ์์ฑ์ผ๋ก ์ํ๋ ๊ฐ์ ๋ฃ์ด์ฃผ๋ฉด, px ์ธ์ ๋ค๋ฅธ ๋จ์๋ฅผ ์ฌ์ฉํ๋ฉด์ width์ height ๊ฐ์ ์ง์ ํ ์ ์๋ค.
์ข์ ๊ธ ๊ฐ์ฌํฉ๋๋ค.