I am trying to show an image as a default when no image is selected.
var photoContentHtml = "";
if (restService.category === "Photo") {
photoContentHtml = "<img onerror='this.onerror=null;this.src=\'http://app.org/layerimages/noimage.jpg\'' src='http://app.org/layerimages/{photo}' width='200px' height='150px'>";
}
but onerror
doesn't seem to work. It keeps returning a broken photo. According to what I see in console, it returns a 404
and gets the path app.org/layerimages/
without the noimage.jpg
.
If I browse the link, it returns the photo and in the app it shows it like this
Any ideas on what I am doing wrong?
Update: No photo uploaded still shows a broken image icon.
Uploaded photo with no image