AdminBundle/Service/YoutubeService.php
public function getThumbnails($videoId, $format = null)
    {
        $listResponse = $this->videos->listVideos('snippet', array('id' => $videoId));
        if (empty($listResponse)) {
            throw new \RuntimeException(sprintf('Could not find video with id %s', $videoId));
        }
        $video = $listResponse[0];
        $videoSnippet = $video['snippet'];
        if (is_null($format)) {
            return $videoSnippet['thumbnails']['data'];
        }
        if (!in_array($format, array('default', 'medium', 'high'))) {
            throw new \InvalidArgumentException(sprintf('Invalid format "%s"', $format));
        }

        return $videoSnippet['thumbnails']['data'][$format];
    }
public function getThumbnails($videoId, $format = null)
    {
        $listResponse = $this->videos->listVideos('snippet', array('id' => $videoId));
        if (empty($listResponse)) {
            throw new \RuntimeException(sprintf('Could not find video with id %s', $videoId));
        }
        $video = $listResponse[0];
        $videoSnippet = $video['snippet'];
        if (is_null($format)) {
            return $videoSnippet['thumbnails']['data'];
        }
        if (!in_array($format, array('default', 'medium', 'high'))) {
            throw new \InvalidArgumentException(sprintf('Invalid format "%s"', $format));
        }

        return $videoSnippet['thumbnails']['data'][$format];
    }
public function getThumbnails ( $ videoId , $ format = null ) { $ listResponse = $ this -> videos -> listVideos ( 'snippet' , array ( 'id' => $ videoId ) ) ; if ( empty ( $ listResponse ) ) { throw new \ RuntimeException ( sprintf ( 'Could not find video with id %s' , $ videoId ) ) ; } $ video = $ listResponse [ 0 ] ; $ videoSnippet = $ video [ 'snippet' ] ; if ( is_null ( $ format ) ) { return $ videoSnippet [ 'thumbnails' ] [ 'data' ] ; } if ( ! in_array ( $ format , array ( 'default' , 'medium' , 'high' ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid format "%s"' , $ format ) ) ; } return $ videoSnippet [ 'thumbnails' ] [ 'data' ] [ $ format ] ; }
Get thumbnails of a video
You can specify a format. If so, you get a single thumbnail of specified format,
otherwise you get an array with all three available formats

@param  string $videoId
@param  string $format  "default", "medium", "high", or null
@return array
Get thumbnails of a video You can specify a format . If so you get a single thumbnail of specified format otherwise you get an array with all three available formats