WebImageView.URL => show standard picture when picture is not aviable

I have some pictures which I’ll load with WebImageView.URL .

From time to time, when my user have a typo in the picture name, the Xojo WebApp shows me in Safari a small blue question mark.

I have a default error photo “Picture not found” in 256x256 pixel. I want to display it, if the picture isn’t found on the server, which I pass via WebImageView.URL = “”.

Is there a method to proof, if the picture is aviable ?

E.g. something like this:

WebImageView.URL = "https://www.domain.com/pictures/500.png" 

if WebImageView.URL.Errorcode = "404" then 
 WebImageView.URL = "https://www.domain.com/pictures/error.png" 
end if

You can use WebHTMLViewer instead of WebImageView and show an HTML document in it with an img tag to show the image. The img tag has an onerror thing you can use.

Pseudo HTML code:

<img src="https://www.domain.com/pictures/500.png"  onerror="this.src='https://www.domain.com/pictures/error.png'"> 

Another way could be to check if the file exists on the server with FolderItem.Exist and show your error image if it does not.

If the url doesn’t point to your server, you could use an httpsocket to see if it exists too.