File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,8 @@ export class ImgLoader implements OnInit {
118
118
}
119
119
120
120
this . imageLoader . getImagePath ( this . imageUrl )
121
- . then ( ( imageUrl : string ) => this . setImage ( imageUrl ) ) ;
121
+ . then ( ( imageUrl : string ) => this . setImage ( imageUrl ) )
122
+ . catch ( ( error : any ) => this . setImage ( this . fallbackUrl || this . imageUrl ) ) ;
122
123
}
123
124
124
125
private setImage ( imageUrl : string ) : void {
@@ -159,7 +160,7 @@ export class ImgLoader implements OnInit {
159
160
this . renderer . setElementStyle ( element , 'background-repeat' , this . backgroundRepeat ) ;
160
161
}
161
162
162
- this . renderer . setElementStyle ( element , 'background-image' , 'url(\'' + imageUrl + '\')' ) ;
163
+ this . renderer . setElementStyle ( element , 'background-image' , 'url(\'' + imageUrl + '\')' ) ;
163
164
}
164
165
}
165
166
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export class ImageLoader {
52
52
* @returns {Promise<string> } Returns a promise that will always resolve with an image URL
53
53
*/
54
54
getImagePath ( imageUrl : string ) : Promise < string > {
55
- return new Promise < string > ( ( resolve ) => {
55
+ return new Promise < string > ( ( resolve , reject ) => {
56
56
57
57
let getImage = ( ) => {
58
58
this . getCachedImagePath ( imageUrl )
@@ -67,7 +67,7 @@ export class ImageLoader {
67
67
resolve ( localPath ) ;
68
68
} )
69
69
. catch ( ( e ) => {
70
- resolve ( imageUrl ) ;
70
+ reject ( ) ;
71
71
this . throwError ( e ) ;
72
72
} ) ;
73
73
} ) ;
You can’t perform that action at this time.
0 commit comments