Check whether the image exists before returning the url