Detecting a dead link

Hello, I’ve been looking for a while but have not found anything thus far. I am trying to detect when an image leads to a 404 page, for example

and return a yes or no as a result of whether or not its an actual image or not. Any help is much appreciated, thanks!