5

In an Angular 15.1.x project, i'm trying implement an image that is responsive on mobile and desktop using NgOptimizedImage. The mandatory img width and height attributes are overriding the sizes attribute.

<img ngSrc="image.png" width="617" height="505" sizes="(max-width: 768px) 276w, 317w">.

According to the docs, this should mean if viewport 768px or less image width should display 276px wide otherwise 317px. I'm using the intrinsic for width/height as per docs. The image always shows at whatever the width/height attribute is (617px X 505px).

Essentially i'm trying to achieve this but using ngSrc:

<img src="image.png" srcset="img.png 617w" sizes="(max-width: 768px) 276px, 317px" >

drav
  • 498
  • 1
  • 4
  • 15

0 Answers0