nuxt / image

Plug-and-play image optimization for Nuxt applications.
https://image.nuxt.com
MIT License
1.32k stars 267 forks source link

Dropped srcset candidate "<URL>" #1133

Open w3bsite opened 9 months ago

w3bsite commented 9 months ago

I get this error only when I use this module.

Failed parsing 'srcset' attribute value since it has an unknown descriptor.

Capture

grandant commented 2 months ago

Hi,

I have been having the same problem recently. It turns out it was because I didn't specify default image size in pixels but rather in view-width. Once I put some appropriate default size in pixels the message disappeared. Something like this:

<!-- Value for sizes was "90vw lg:200px xl:500px" -->
<NuxtImg
            format="webp"
            :src="`/media/plays/${mainAccent.slug}/photos/7.jpg`"
            :alt="`${mainAccent.name} - Poster`"
            class="img-fluid w-100 border border-3"
            sizes="250px lg:200px xl:500px"
            :placeholder="[5]"
            loading="lazy"
          />

I am not sure if that's an error on my side or if NuxtImage is intended to work like this. Hope this helps someone.