diff --git a/functions.php b/functions.php index 95baacd2bd5a7b101469b4b81dbe0e975711522d..c4016efe01585acbc1267656d98ae5d5ab421c14 100644 --- a/functions.php +++ b/functions.php @@ -134,12 +134,16 @@ function get_query_by_category( $category, $nb_posts = -1, $offset = 0 ) { return new WP_Query( $args ); } - +function UR_exists($url){ + $headers=get_headers($url); + return stripos($headers[0],"200 OK")?true:false; +} // 'thumbnail_large', 'thumbnail_medium', 'thumbnail_small' function get_vimeo_image( $vimeoId, $size = 'thumbnail_large' ) { - if(is_file("http://vimeo.com/api/v2/video/" . $vimeoId . ".json")){ - $data = file_get_contents("http://vimeo.com/api/v2/video/" . $vimeoId . ".json"); + $json_url = "http://vimeo.com/api/v2/video/" . $vimeoId . ".json"; + if(UR_exists($json_url)){ + $data = file_get_contents($json_url); $data = json_decode($data); return $data[0]->{$size}; }else{