img-exists

1.0.2 • Public • Published

Image Exists npm Package

Check if remote image exists

Features

  • Ping single remote image or an array of images
  • Does not consume time and traffic downloading the whole image
  • Cross browser (after Babel), pure vanilla js

API

ImageExists(input[, options], complete)

input

Type: String | Array
Single url, or an array of urls

options.timeout

Type: Number
Default: 1000 ms
Wait for a server response

complete

Type: Function
Callback function

Usage

let images = [
   'https://www.instagram.com/static/images/homepage/home-phones.png/43cc71bb1b43.png', 
   'https://assets.nationalgeographic.com/styleguide/stable/logos/ng-logo-2fl.svg', 
   'https://royalmail.com/sites/all/themes/royalmail2017/img/royalmail-logo.png',
   'https://avatars3.githubusercontent.com/u/18248992?s=40&v=4'
];
 
ImageExists(images, { timeout: 1000 }, (err, result) => {
   if(err){
      // ...
   }
 
   // ...
});

Package Sidebar

Install

npm i img-exists

Weekly Downloads

5

Version

1.0.2

License

MIT

Unpacked Size

5.04 kB

Total Files

5

Last publish

Collaborators

  • tpkn