diff --git a/src/Entity/Capsule.php b/src/Entity/Capsule.php index faaf02e4c5236a6df7c4dd6da3d20b3a3140e00f..922b3e861b5e90078b078de755636cce93b1972b 100755 --- a/src/Entity/Capsule.php +++ b/src/Entity/Capsule.php @@ -201,25 +201,25 @@ class Capsule } try { - $project_retriever = new ProjectRetriever($this); - $video_url = $project_retriever->getVideoUrl(); - $video_id = $project_retriever->getVideoId($video_url); - - if (str_contains($video_url, 'yout')) { - $url = 'https://img.youtube.com/vi/%s/%s.jpg'; - $high_resolution = sprintf($url, $video_id, 'maxresdefault'); - $medium_resolution = sprintf($url, $video_id, 'mqdefault'); - try { - $http_client->request('GET', $high_resolution); - return $high_resolution; - } catch (\Exception $e) { - return $medium_resolution; + $project_retriever = new ProjectRetriever($this); + $video_url = $project_retriever->getVideoUrl(); + $video_id = $project_retriever->getVideoId($video_url); + + if (str_contains($video_url, 'yout')) { + $url = 'https://img.youtube.com/vi/%s/%s.jpg'; + $high_resolution = sprintf($url, $video_id, 'maxresdefault'); + $medium_resolution = sprintf($url, $video_id, 'mqdefault'); + try { + $http_client->request('GET', $high_resolution); + return $high_resolution; + } catch (\Exception $e) { + return $medium_resolution; + } } - } - return 'https://vumbnail.com/' . $video_id . '.jpg'; + return 'https://vumbnail.com/' . $video_id . '.jpg'; } catch (\Exception $e) { - return null; + return null; } }