8

In Next.js app, am using Image component. I want to load an image with auto height and width.

 <div style={{ height:'',width:'' }}>
    <Image 
       src={imgLink}
       objectFit="cover"
       layout="fill"
    />
 </div>

I can easily achieve this if i can specify height and width in its parent div. but what i want is to load it in its natural height. Is there something am missing ?

I found a similar question in stackoverflow. How to use Image component in Next.js with unknown width and height .But no success. Isn't there any other way to achieve this ? should I need to stick with img?

Hari Warshan
  • 153
  • 1
  • 8

0 Answers0