Skip to content

fix(common): allow mixed pixel and responsive values in NgOptimizedIm…#67070

Open
Rajveer173 wants to merge 1 commit intoangular:mainfrom
Rajveer173:fix/ng-optimized-image-allow-mixed-sizes
Open

fix(common): allow mixed pixel and responsive values in NgOptimizedIm…#67070
Rajveer173 wants to merge 1 commit intoangular:mainfrom
Rajveer173:fix/ng-optimized-image-allow-mixed-sizes

Conversation

@Rajveer173
Copy link

Fixes #59495

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other

What is the current behavior?

The assertNoComplexSizes validation in NgOptimizedImage rejects any sizes attribute containing pixel (px) values, even when those pixel values are used alongside responsive units such as vw.

This prevents valid use cases where a pixel fallback is intentionally combined with responsive media queries.

What is the new behavior?

The heuristic now throws only when the sizes attribute contains exclusively pixel values and no responsive units.

If responsive units (e.g., vw) are present alongside pixel values, validation passes.

This ensures:

  • Valid responsive configurations are allowed.
  • Fixed-size configurations still trigger guidance to omit sizes and rely on 1x/2x density descriptors.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This change aligns validation behavior with real-world responsive image patterns while preserving guidance for fixed-size usage.

…age sizes

The assertNoComplexSizes validation in NgOptimizedImage previously rejected any sizes attribute containing pixel values, even when those pixel values appeared alongside responsive units like vw. This prevented valid use cases where a pixel fallback is intentionally combined with responsive media queries.

The heuristic now only throws when the sizes attribute contains exclusively pixel values with no responsive units, which indicates the user likely wants fixed-size mode and should omit sizes to get proper 1x/2x density descriptors instead.

Fixes angular#59495
@pullapprove pullapprove bot requested a review from JeanMeche February 14, 2026 12:39
@angular-robot angular-robot bot added the area: common Issues related to APIs in the @angular/common package label Feb 14, 2026
@ngbot ngbot bot added this to the Backlog milestone Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: common Issues related to APIs in the @angular/common package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove assertNoComplexSizes from NgOptimizedImage

1 participant