File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,6 @@ module.exports = function draw(gd) {
8585 }
8686
8787 thisImage . attr ( {
88- href : d . source ,
8988 x : xPos ,
9089 y : yPos ,
9190 width : width ,
@@ -95,6 +94,22 @@ module.exports = function draw(gd) {
9594 } ) ;
9695
9796
97+ // Images load async so we must add the promise to the list
98+ var imagePromise = new Promise ( function ( resolve ) {
99+
100+ thisImage . on ( 'load' , resolve ) ;
101+ thisImage . on ( 'error' , function ( ) {
102+ thisImage . remove ( ) ;
103+ console . log ( 'Image with source ' + d . source + ' could not be loaded.' ) ;
104+ resolve ( ) ;
105+ } ) ;
106+
107+ thisImage . attr ( 'href' , d . source ) ;
108+ } ) ;
109+
110+ gd . _promises . push ( imagePromise ) ;
111+
112+
98113 // Set proper clipping on images
99114 var xId = xref ? xref . _id : '' ,
100115 yId = yref ? yref . _id : '' ,
You can’t perform that action at this time.
0 commit comments