I tried using this simple JavaScript function in the template to check if an image URL exists / is valid:

<script language="JavaScript">
function imageExists(url) 
        var img = new Image();
        img.src = url;
        return img.height != 0;

Then do something like this to react on the result of the check:

if ( imageExists("http://some.domain.net/snaps/$ID$.png") )
        document.write("<img src=\"http://some.domain.net/snaps/$ID$.png\">");
        document.write("<img src=\"$GHOST_IMAGE$\">");

Works nicely here!

A mind is like a parachute. It doesn't work unless it's open. [Frank Zappa]