Skip to content

Instantly share code, notes, and snippets.

@arnaudbreton
Last active December 18, 2015 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnaudbreton/5752427 to your computer and use it in GitHub Desktop.
Save arnaudbreton/5752427 to your computer and use it in GitHub Desktop.
Providing a custom thumbnail for a Google Drive app.
html2canvas(document.getElementById('editor'),
{
onrendered: function (canvas) {
doc.dirty = false;
// doc.info is the File structure
var data = angular.extend({}, doc.info);
if (doc.info.editable) {
data.content = doc.info.content;
data.thumbnail = {
// Base 64 URL friendly
"image": canvas.toDataURL().split(',')[1].replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, ''),
"mimeType": "image/png"
};
}
return defer.resolve(data);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment