이번에는 Next.js에서사용하는 이미지태그 ,Image태그에 대해서 알아보자!
Pinterest에서 BMO를 검색해서 이미지 주소를 복사해줬다.
https://i.pinimg.com/474x/3f/fb/b1/3ffbb1ff45985098834eabcf8d55548e.jpg
주소는 다음과 같다 .
이렇게 써주면,,,!
이렇게 오류가 야무지게 발생한다.
Error: Invalid src prop (https://i.pinimg.com/474x/3f/fb/b1/3ffbb1ff45985098834eabcf8d55548e.jpg) onnext/image
, hostname "i.pinimg.com" is not configured under images in yournext.config.js
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "i.pinimg.com" //이렇게 추가해준다.
}
]
}
}
module.exports = nextConfig
BMO가 잘 출력된 것을 볼 수 있다.
보시면 아까 언급했던 디바이스 크기별 이미지를 나눠주어서 용량을 최적화 시킨 것을 알 수 있다. (1x,2x등.. )