Проверка наличия картинки

function url_exists($url){
    $ch = curl_init($url);    
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_exec($ch);
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

   return ($code == 200);
}

$url = url_exists("http://logo.clearbit.com/ryanm.com") ? 
    "http://logo.clearbit.com/ryanm.com" : 
    "<alternate_url>";
 11   9 мес   php