From 269b93e888c837c8285813bbef369db30d63fa78 Mon Sep 17 00:00:00 2001 From: tranek Date: Fri, 24 May 2013 16:38:43 -0400 Subject: [PATCH] Added data URLs for Rasters in Node.js --- src/item/Raster.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/item/Raster.js b/src/item/Raster.js index 5899222f..1334137a 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -297,11 +297,17 @@ var Raster = this.Raster = Item.extend(/** @lends Raster# */{ image.src = src; } /*#*/ } else if (options.server) { - // If we're running on the server and it's a string, - // load it from disk: - // TODO: load images async, calling setImage once loaded as above var image = new Image(); - image.src = fs.readFileSync(src); + // If we're running on the server and it's a string, + // check if it is a data URL + var protocol = src.split('/')[0]; + if (protocol && protocol.equals("data:image")) { + image.src = src; + } else { + // load it from disk: + // TODO: load images async, calling setImage once loaded as above + image.src = fs.readFileSync(src); + } /*#*/ } // options.server this.setImage(image); },