Create IMG element

Create an IMG element

$ npm install img

A basic usage of it would be:

var img = require('img')
var el = img('')

You can also pass a callback, it'll be called when the img is load or failed to load:

img('', function (errorel) {
  // image is loaded 
  // =>  

To set timeout:

var img = require('img')
var timeout = require('callback-timeout')
img('loads-very-slow.gif', timeout(function (errorel) {
  // => "Timeout" 
}, 2000))

Optional crossOrigin parameter:

var img = require('img')
img('path/to/file.png', { crossOrigin: 'Anonymous' }, function(errimage) {

See test.js for more info.