Created
September 26, 2012 17:06
-
-
Save johnistan/3789222 to your computer and use it in GitHub Desktop.
Image Copy from Clipboard - Chrome only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$doc.onpaste = function(event){ | |
var items = event.clipboardData.items; | |
console.log(JSON.stringify(items)); // will give you the mime types | |
var blob = items[0].getAsFile(); //really should loop through | |
var reader = new $wnd.FileReader(); | |
reader.onloadend = (function(event){ | |
return function(){ | |
var image = new Image(); | |
image.title = "test"; | |
console.log(this.result); | |
image.src = /^image/.test(this.type) ? this.result : this.result; | |
image.id = "testid"; | |
$wnd.$('#imageAnchor').after( image ); | |
} | |
})(blob); | |
reader.readAsDataURL(blob); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment