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) {
85
85
}
86
86
87
87
thisImage . attr ( {
88
- href : d . source ,
89
88
x : xPos ,
90
89
y : yPos ,
91
90
width : width ,
@@ -95,6 +94,22 @@ module.exports = function draw(gd) {
95
94
} ) ;
96
95
97
96
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
+
98
113
// Set proper clipping on images
99
114
var xId = xref ? xref . _id : '' ,
100
115
yId = yref ? yref . _id : '' ,
You can’t perform that action at this time.
0 commit comments