Non-background pictures can be judged using img's onerror, but as for background pictures, I just accidentally discovered a method that is feasible by visual inspection, but I am not sure whether it is always feasible.
var img=new Image();
img .src="image address";
if(img.width==0){//Indicates that the image loading failed}
else{//Successful}
This method It is generally feasible, but we have tested whether it is feasible when the image is very large or the loading speed is very slow.