1

The Image component provided by Next.js requires you to set the image's intristic width and height.

import Image from 'next/image'

export default function Index(props) {
    return (
        <div>                   
            <Image
                layout="intrinsic"
                width={774}
                height={1161}
                src="https://images.unsplash.com/photo-1662572163236-630fd5bcc99d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=687&q=80"
            />
        </div>
    )
}

How can I automatically get the intrinsic image height and width so that I do not have to manually figure out the intrinsic size each time I use the image component?

  • What have you tried? You're expected to make an effort and show your code. – isherwood Sep 09 '22 at 15:02
  • Does this answer your question: [How to use Image component in Next.js with unknown width and height](https://stackoverflow.com/a/71096113/1870780)? – juliomalves Sep 10 '22 at 17:38

0 Answers0