Using image width and height in case of responsive images
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 331
- Avg merge
- 19h 52m
- Merged PRs (30d)
- 9
Description
<nuxt-img
src="/images/abc.png"
sizes=" xl:100vw xxl:100vw xxxl:100vw"
/>
works fine but in lighthouse, it generates an warning like the following -
Set an explicit width and height on image elements to reduce layout shifts and improve CLS
As per this documentation -
https://image.nuxtjs.org/components/nuxt-img
Use original image width/height for responsive images (when using sizes)
Width of my actual image is 1930 and height is 333
So when I try to add width and height as 1930 and 333, the image is not responsive anymore. Am I missing something here ? please advise.
<nuxt-img
src="/images/abc.png"
width="1920"
height="333"
sizes=" xl:100vw xxl:100vw xxxl:100vw"
/>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the nuxt-img component and compare the documented responsive-image behavior with the supplied width, height, and sizes attributes. Reproduce the Lighthouse warning using the example values, then verify that the final behavior preserves responsiveness while providing the explicit dimensions Lighthouse expects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100