Incase the URL is corrupted or storage remove the images then url will not load image & hence blank image is displayed. I just want to show default image in that case.
I tried looking into successFunction but i dont think on error this will help out.
Any clue will be greatly appreciated.
I just tried it, and I find that the Picture.errorFunction does indeed get called. I have a similar Picture:
$(go.Picture, "nonexistent.jpg",
{
width: 50, height: 50,
errorFunction: function(pic, e) {
pic.diagram.commit(function() {
pic.source = "../samples/images/hs1.jpg";
}, null); // null means temporarily set skipsUndoManager to true
}
})
The console & network activity shows getting a 404 error, and the errorFunction is called, substituting the image source successfully.
I also tried it so that the substitute image source would result in 404 errors, and that worked correctly too, causing the Picture not to show anything at all.
If the image doesn’t load, it won’t show anything. There’s no way to avoid the 404 error if the URL fails to find an image resource, but by default that’s not shown in the diagram.
That error function is a property of the Picture class: