code: function(imageElement) {
  			_readyCb = function() {
  				try {
  					var w = imageElement.width;
  					var h = imageElement.height;
  					var newImg = document.createElement('img');
  					var ratio = (w / _w < h / _h) ? (w / _w) : (h / _h);
  					newImg.setAttribute('src', imageElement.getAttribute('src'));
  					newImg.height = (h / ratio);
  					newImg.width = (w / ratio);
  					_context.clearRect(0, 0, _w, _h);
  					_context.drawImage(newImg, 0, 0, _w, _h);
  					link.setIcon(_canvas);
  				} catch(e) {
  					throw 'Error setting image. Message: ' + e.message;
  				}
  			};
  			if (_ready) {
  				_readyCb();
  			}
  		}
docs: Set image as icon