Create an IMG element
$ npm install npm-dom/img
A basic usage of it would be:
var img = require('img') var el = img('https://avatars2.githubusercontent.com/u/7551498') document.body.appendChild(el)
You can also pass a callback, it'll be called when the img is load or failed to load:
img('https://avatars2.githubusercontent.com/u/7551498', function (error, el) { // image is loaded error // => undefined document.body.appendChild(el) })
To set timeout:
var img = require('img') var timeout = require('callback-timeout') img('loads-very-slow.gif', timeout(function (error, el) { error.message // => "Timeout" }, 2000))
Optional crossOrigin parameter:
var img = require('img') img('path/to/file.png', { crossOrigin: 'Anonymous' }, function(err, image) { console.log(image) })
See test.js
for more info.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4