https://github.com/tpkn/image-exists
Check if remote image exists
https://github.com/tpkn/image-exists
Last synced: about 1 month ago
JSON representation
Check if remote image exists
- Host: GitHub
- URL: https://github.com/tpkn/image-exists
- Owner: tpkn
- License: mit
- Created: 2019-02-08T22:43:13.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T20:57:00.000Z (over 6 years ago)
- Last Synced: 2025-02-14T20:03:07.091Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.83 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Image Exists [](https://www.npmjs.org/package/img-exists)
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
```javascript
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
```javascript
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){
// ...
}
// ...
});
```