diff --git a/FeedsYoutubeParser.inc b/FeedsYoutubeParser.inc index aa3c864..5ad7867 100644 --- a/FeedsYoutubeParser.inc +++ b/FeedsYoutubeParser.inc @@ -233,8 +233,18 @@ class FeedsYoutubeParser extends FeedsParser { $watch = str_replace('&feature=youtube_gdata_player', '', $attrs['url']); // Get video thumbnail. - $attrs = $media->group->thumbnail[0]->attributes(); - $thumbnail = (string) $attrs['url']; + foreach($media->group->thumbnail as $thumb) { + $attrs = $thumb->attributes('http://gdata.youtube.com/schemas/2007'); + if ($attrs['width'] == '480') { + $attrs = $thumb->attributes(); + $thumbnail = (string) $attrs['url']; + } + } + + if (!isset($thumbnail)) { + $attrs = $media->group->thumbnail[0]->attributes(); + $thumbnail = (string) $attrs['url']; + } // Get node for video length. $yt = $media->children('http://gdata.youtube.com/schemas/2007');