1.2.0 • Published 5 months ago

ngx-broken-img v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 months ago

ngx-broken-img

npm

Angular 2+ directive to fix broken url in img.
If image url returns 404 a placeholder is used to fill img's src.

Demo

https://stackblitz.com/edit/ngx-broken-img

Install

npm

npm install ngx-broken-img --save

yarn

yarn add ngx-broken-img

Setup

step 1: add NgxBrokenImgModule to app NgModule

import { CommonModule } from '@angular/common';
import { NgxBrokenImgModule } from 'ngx-broken-img';

@NgModule({
  imports: [
    CommonModule,
    NgxBrokenImgModule,
  ],
  bootstrap: [App],
  declarations: [App],
})
class MainModule {}

Use

<!-- Default placeholder -->
<img src="http://somebrokenurl" ngxBrokenImage>

<!-- Custom base64 placeholder -->
<img src="http://somebrokenurl" ngxBrokenImage="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mM88x8AAp0BzdNtlUkAAAAASUVORK5CYII="> 
1.2.0

5 months ago

1.1.0

2 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.0

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago