getCleanedUrl(); $embed_url = null; // http://youtu.be/9hQVA2sloGc if (preg_match("#\/([a-zA-Z0-9]+)#", $url, $chaines)) { $embed_url = 'http://www.youtube.com/embed/'.$chaines[1]; } if ($embed_url) { $width = $this->container->getParameter('youtube_player_width'); $height = $this->container->getParameter('youtube_player_height'); return ''; } return null; } public function getThumbnailUrl() { $url_object = $this->getCleanedUrl(); $url = null; // http://youtu.be/9hQVA2sloGc if (preg_match("#\/([a-zA-Z0-9]+)#", $url_object, $chaines)) { $url = 'http://img.youtube.com/vi/'.$chaines[1].'/default.jpg'; } return $url; } }