Enter your email below to get insights on starting, running and growing a creative company

Access clipboard image data, cross browser (even Safari)

Allowing users to paste images from their clipboards directly into a web app is a great way of bringing a desktop-like experience to the web. However browser support for this functionality is a little all over the place (Safari, I'm looking at you).

Happily as is so often the case on the internet, a kindly soul (in this case Michael Yin) has done the hard work for you and wrapped it up in a neat little jQuery plugin. Just drop it in and cross browser image pasting is yours. My only regret is not finding this sooner.

Paste.js on Github

// Capture paste event on the whole document 
$('html').pastableNonInputable();
$('*').on('pasteImage', function (ev, data){
  // Do something with the image (data.dataURL)
}.bind(this)).on('pasteImageError', function(ev, data){
  // Do something with the error
}).on('pasteText', function (ev, data){
  // Do something with text
});
Posted August 2017
© 2014-2018 James Chambers
Learn from my mistakes
x

Sign up to my mailing list to get insights about starting, running and growing a creative company.