Today I Learned

A collection of useful bits & bobs I'd rather not forget
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
});
JAVASCRIPT
Things I learned on other days →