Fix broken image path (#463)
* Fix broken image path * switch to use .endsWith instead of ==
This commit is contained in:
parent
a310e6ee7f
commit
d280e932f9
|
@ -1,6 +1,6 @@
|
||||||
import {Directive, ElementRef, HostListener, Input} from '@angular/core';
|
import {Directive, ElementRef, HostListener, Input} from '@angular/core';
|
||||||
|
|
||||||
const DEFAULT_IMAGE_FALLBACK_PATH: string = '/assets/images/no-image.svg';
|
const DEFAULT_IMAGE_FALLBACK_PATH: string = 'assets/images/no-image.svg';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: 'img[imageFallback]'
|
selector: 'img[imageFallback]'
|
||||||
|
@ -14,7 +14,7 @@ export class ImageFallbackDirective {
|
||||||
loadFallbackOnError() {
|
loadFallbackOnError() {
|
||||||
// Check to see if we have already tried to load the fallback image.
|
// Check to see if we have already tried to load the fallback image.
|
||||||
// Avoids endless loop if for some reason fallback image is missing. Just accept the broken image.
|
// Avoids endless loop if for some reason fallback image is missing. Just accept the broken image.
|
||||||
if (this.path(this.elementRef.nativeElement.src) == this.path(this.fallbackSrc())) {
|
if (this.path(this.elementRef.nativeElement.src).endsWith(this.path(this.fallbackSrc()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue