Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to auto-height an Image using only a width? #26

Open
opendeluxe opened this issue Jun 23, 2023 · 0 comments
Open

How to auto-height an Image using only a width? #26

opendeluxe opened this issue Jun 23, 2023 · 0 comments

Comments

@opendeluxe
Copy link

As already written here (vercel/nextjs-portfolio-starter#32) at the base template, I want to put images into a blog post with a fixed width but an automatically calculated height. How to do that?

Using code like

<Image
  src="/photos/test.jpg"
  alt="Photo"
  width={200}
  priority
  className="next-image"
/>

will return the error message:

Error: Image with src "/photos/test.jpg" must use "width" and "height" properties or "layout='fill'" property.

The property "layout=fill" doesn't work either, as it strechtes the image over the full screen size.

any ideas how to do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant