From 45d29da0e443d05fc93e6d9c043fb93b72feb4fb Mon Sep 17 00:00:00 2001
From: "B. Ninassi" <benjamin.ninassi@inria.fr>
Date: Fri, 1 Oct 2021 16:13:52 +0200
Subject: [PATCH] correction vignettes vimeos

---
 functions.php | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/functions.php b/functions.php
index 95baacd..c4016ef 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{
-- 
GitLab