Skip to content

Preset sizes not applied when component sizes prop is undefined #1918

@tyminko

Description

@tyminko

Bug Report

Description

When using image presets with defined sizes in nuxt.config.ts, the preset sizes are not applied if the component's sizes prop is undefined. This causes the image to fallback to density-based srcset (1x, 2x) instead of the expected width-based srcset (320w, 640w, etc.), leading to incorrect image serving.

Reproduction

// nuxt.config.ts
export default defineNuxtConfig({
  image: {
    presets: {
      responsive: {
        sizes: '100vw sm:50vw md:400px'
      }
    }
  }
})
<!-- Component usage -->
<NuxtImg 
  src="/image.png" 
  preset="responsive"
  :sizes="undefined"  // or simply omitted
  width="300" 
  height="400" 
/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions