nuxt / nuxt/image

Setting height on a <nuxt-picture> will lead to a different result than a <nuxt-img>

Open
#422 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
331
Avg merge
19h 52m
Merged PRs (30d)
9

Description

Hello, we found a small inconsistency between nuxt-picture and nuxt-image. If you add two images and only set the height, the nuxt image will resize the image the image while the nuxt-picture will crop. You can see a reproduction in this sandcodebox.

In the image below you see

<nuxt-img src="/images/portrait-mountains.jpg" height="200px" />
<nuxt-picture src="/images/portrait-mountains.jpg" height="200px" />
 <nuxt-img src="/images/mountains.jpg" height="200px" />
 <nuxt-picture src="/images/mountains.jpg" height="200px" />
screen

It seems to be caused due to nuxt-picture adding responsive image sizes by default, this then sets the width defined in the screens and the height set defined on the component as a fixed value. My guess is that this is related to the issue mentioned here https://github.com/nuxt/image/issues/238

the nuxt-img component shows the images like expected

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and compare the nuxt-img and nuxt-picture examples that set only height. Inspect how nuxt-picture's default responsive image sizes interact with the component height, including the related issue #238. Done means both components produce consistent sizing for the portrait and landscape examples without unintended cropping.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.