ionic-team / ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
127 stars 85 forks source link

ion-img onerror #690

Open ionitron-bot[bot] opened 5 years ago

ionitron-bot[bot] commented 5 years ago

Original issue by @pickfire on 2018-09-19T08:22:41Z

Feature Request

Ionic Info

✔ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)  : 4.1.1 (/usr/local/share/.config/yarn/global/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.11

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : no whitelisted plugins (12 plugins total)

System:

   Android SDK Tools : 26.1.1 (/opt/android-sdk)
   NodeJS            : v10.10.0 (/usr/bin/node)
   npm               : 6.4.1
   OS                : Linux 4.18

   ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 4.1.1 → 4.1.2    │
   │    Run npm i -g ionic to update     │
   │                                     │
   ╰─────────────────────────────────────╯

Describe the Feature Request

Add support for ion-img to handle error during lazy loading. Currently only img supports onerror but ion-img does not.

onerror is useful when we want to fallback to a default image. Such as:

<ion-img [src]="image.src" onerror="this.src='assets/img/profile.svg'"></ion-img>

Describe Preferred Solution

onerror support.

Describe Alternatives

Use img but there is no lazy loading.

Related Code

-

Additional Context

-

chenlitchian commented 4 years ago

any update for this issue?

pickfire commented 4 years ago

This is already there.

chenlitchian commented 4 years ago

This is already there.

I have tried but fail. Please help.

image

   <ion-img [src]="image" onerror="this.src='https://via.placeholder.com/150'"></ion-img>
    <img [src]="image" onerror="this.src='https://via.placeholder.com/150'"/>
chenlitchian commented 4 years ago

@pickfire

image

pickfire commented 4 years ago

Can you please check the source code? IIRC it is (onerror) or (error), I don't recall. (I was also the one who wrote it IIRC but I don't recall how was it called)

sanjaya-leecare commented 4 years ago

Hey @chenlitchian did you get this sorted? I tried both onerrorand errorand none of them worked for me. I'm on ionic 5.0.0

snakone commented 3 years ago

bump

3zzy commented 2 years ago

bump