why does Image component need width and height? I only want to put width to maintai the aspect ratio
Answered
NuclearMonkey posted this in #help-forum
why does Image component need width and height? I only want to put width to maintai the aspect ratio
Answered by Ray
there is example in the doc
https://nextjs.org/docs/app/building-your-application/optimizing/images#examples
https://nextjs.org/docs/app/building-your-application/optimizing/images#examples
4 Replies
@NuclearMonkey why does Image component need width and height? I only want to put width to maintai the aspect ratio
width and height are needed for remote image. you don't need to provide it if you are importing a local image
https://nextjs.org/docs/pages/building-your-application/optimizing/images#remote-images
https://nextjs.org/docs/pages/building-your-application/optimizing/images#remote-images
@Ray width and height are needed for remote image. you don't need to provide it if you are importing a local image
https://nextjs.org/docs/pages/building-your-application/optimizing/images#remote-images
okay, but what if I just want to put width on the remote image because I want to maintain the aspect ratio, but nextjs requires to put height
Answer