Fixed data URLs src disappearing

This commit is contained in:
tranek 2013-05-24 20:55:59 -04:00
parent cd7938e363
commit 1637127e09

View file

@ -300,9 +300,10 @@ var Raster = this.Raster = Item.extend(/** @lends Raster# */{
var image = new Image(); var image = new Image();
// If we're running on the server and it's a string, // If we're running on the server and it's a string,
// check if it is a data URL // check if it is a data URL
var protocol = src.split('/')[0]; if (src.indexOf('data:') == 0) {
if (protocol && protocol == "data:image") {
image.src = src; image.src = src;
// Preserve the src as canvas-node eats it
image._src = src;
} else { } else {
// load it from disk: // load it from disk:
// TODO: load images async, calling setImage once loaded as above // TODO: load images async, calling setImage once loaded as above
@ -341,6 +342,9 @@ var Raster = this.Raster = Item.extend(/** @lends Raster# */{
// See if the linked image is base64 encoded already, if so reuse it, // See if the linked image is base64 encoded already, if so reuse it,
// otherwise try using canvas.toDataURL() // otherwise try using canvas.toDataURL()
var src = this._image && this._image.src; var src = this._image && this._image.src;
/*#*/ if (options.server) {
src = this._image._src;
}
if (/^data:/.test(src)) if (/^data:/.test(src))
return src; return src;
var canvas = this.getCanvas(); var canvas = this.getCanvas();