Skip to content

Implement webp and png formats load both images #480

@Jarigu

Description

@Jarigu

Hello, I have a problem with the implementation of the webp images in my project, the lazy load works fine, but it loads me both images.

Thanks

Angular: 8.2.14

<div class="item" *ngFor="let item of specialties | slice:0:10 ; let indexOfElement = index; ">
  <a (click)="buildDataLayerSpecialties(indexOfElement + 1, item.name)" [attr.href]="item.url">
    <picture>
      <source type="image/webp" [attr.defaultImage]="'assets/img/loading.gif'" [attr.lazyLoad]="item.baseImage+'webp/100x100/'+item.icon+'.webp'"/>
      <source type="image/webp" [attr.defaultImage]="'assets/img/loading.gif'" [attr.lazyLoad]="item.baseImage+'100x100/'+item.icon+'.png'" />
      <img [defaultImage]="'assets/img/loading.gif'" [lazyLoad]="item.baseImage+'100x100/'+item.icon+'.png'" alt="{{item.name}}">
    </picture>
  </a>
  <a (click)="buildDataLayerSpecialties(indexOfElement + 1, item.name)" [attr.href]="item.url">{{item.name}}</a>
</div>

code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions