nuxt / nuxt/image

Cloudinary fit values: Width/Height attributes when using fit="fit" don't use actual outcome for Width/Height

Open
#756 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

The Nuxt-Img docs are missing fit="fit". fit="fit" is the same as what Nuxt-Img calls fit="contain".

https://image.nuxtjs.org/providers/cloudinary#cloudinary-fit-values

https://image.nuxtjs.org/components/nuxt-img#fit

When you use fit="contain" with your provider set to Cloudinary, you do not get the expected outcome.

When using fit="fit" you want to either have a max height or width for the image, preserving aspect ratio. This means for the example below that a portrait image will have 500px in height and unknown width - and vice-versa for landscape.

      <nuxt-img
        provider="cloudinary"
        fit="fit"
        :src="imgUrl"
        :height="500"
        :width="500"
      /> 

However, the rendered image gets both attributes set, like so:

      <img
        src="https://res.cloudinary.com/xyz/image/upload/f_auto,q_auto,w_500,h_500,c_fit/xyz/img.jpg" 
        width="500" 
        height="500"
      /> 

Therefore, the browser gets wrong information about how to render the image on the screen.

Would there be a way to get this right without having the image aspect ratio beforehand?

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 Cloudinary fit values and Nuxt-Img fit documentation linked in the issue, then reproduce the provided example with portrait and landscape images. Done means the rendered image dimensions and HTML attributes reflect the actual contain/fit outcome without requiring a known aspect ratio beforehand.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.