mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 23:39:59 -05:00
Fixed data URLs src disappearing
This commit is contained in:
parent
cd7938e363
commit
1637127e09
1 changed files with 6 additions and 2 deletions
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue