/fallback-image

Load a fallback image if an image errors out.

Primary LanguageJavaScript

fallback-image

Load a fallback image if an image errors out.

Circle CI Coverage Status

Installation

$ npm install fallback-image

Usage

import fallbackImage from 'fallback-image';

let imageEl = document.querySelector('img.horse-image');
fallbackImage(imageEl, './images/fallback-image.png');

Standalone

Generate a standalone build in dist (for use with <script> tags and AMD module loaders):

$ npm run build:standalone

Test

Run tests with tape:

$ npm test

License

MIT