Instead of trying to perform this check on the client, I would perdonally recommend recommend handling it at the server end and save yourself (and USERS!) that extra request.
The simplest means (add your own interpretational logic and validation later) would be to have a file called something like "coverart.php" and when you try to get the cover art make a request to coverart.php?name=MY_COVER_ART_FILE
Then within coverart.php:
$strCoverName = $_GET['name'];
$strArtDir = 'YOUR_COVER_ART_DIRECTORY';
$strCommonExtenstion = '.jpg';
$strFile = $strArtDir.$strCoverName.$strCommonExtension;
header('Content-Type: image/jpeg');
if(is_file($strFile)) {
readfile($strFile);
} else {
readfile($strArtDir.'no_img_file'.$strCommonExtension);
}
This is a KISS way of achieving what you want, I'd recommend you look further in to the various ways of achieving this however but along similar lines