Which @angular/* package(s) are relevant/related to the feature request?
common
Description
Currently you can't use pixel values in sizes in NgOptimizedImage.
Code like that:
sizes="(max-width: 540px) 100vw, (max-width: 960px) 50vw, 370px"
will cause NG02952 exception in dev mode, because of assertNoComplexSizes function in NgOptimizedImage directive code. Yet, in production it will produce proper srcset and will render just fine.
I've read NgOptimizedImage source, and I can't find any logic there that can explain why that assertion is necessary.
I have sizes like that (responsive for mobile/tablet, fixed for desktop) in my production code for regular img elements. That limitation of sizes stops me from easily switching to NgOptimizedImage.
Proposed solution
Remove assertNoComplexSizes assertion from NgOptimizedImage source.
Alternatives considered
Add option to disable assertNoComplexSizes assertion conditionally somehow in dev mode.
Which @angular/* package(s) are relevant/related to the feature request?
common
Description
Currently you can't use pixel values in
sizesinNgOptimizedImage.Code like that:
sizes="(max-width: 540px) 100vw, (max-width: 960px) 50vw, 370px"will cause NG02952 exception in dev mode, because of
assertNoComplexSizesfunction inNgOptimizedImagedirective code. Yet, in production it will produce propersrcsetand will render just fine.I've read
NgOptimizedImagesource, and I can't find any logic there that can explain why that assertion is necessary.I have sizes like that (responsive for mobile/tablet, fixed for desktop) in my production code for regular
imgelements. That limitation ofsizesstops me from easily switching toNgOptimizedImage.Proposed solution
Remove
assertNoComplexSizesassertion fromNgOptimizedImagesource.Alternatives considered
Add option to disable
assertNoComplexSizesassertion conditionally somehow in dev mode.