Test To See If An Image With Json Value Is Broken/ Or Not There And Replace With "no-photo" Image?
My team and I are using a backend service to grab json data to display images on the frontend. We have a javascript that will display a 'no-photo.png' image when their is no value
Solution 1:
Set an onerror
callback:
var img = new Image();
img.onerror = function () {
this.src = 'noimage.jpg';
};
img.src = 'path/from/json/img.jpg';
Post a Comment for "Test To See If An Image With Json Value Is Broken/ Or Not There And Replace With "no-photo" Image?"