This article focuses on showing YouTube video thumbnails and Vimeo video thumbnails of the code, the need for friends can refer to the following
function Video_image ($url) { $image _url = Parse_url ($url); if ($image _url[' host '] = = ' www.youtube.com ' | | $image _url[' host '] = = ' youtube.com ') { $array = explode ("&", $image _url[' query ']); Return "http://img.youtube.com/vi/". substr ($array [0], 2). " /0.jpg "; } else if ($image _url[' host '] = = ' www.youtu.be ' | | $image _url[' host '] = = ' youtu.be ') { $array = explode ("/", $image _url[' path '); Return "http://img.youtube.com/vi/". $array [1]. " /0.jpg "; } else if ($image _url[' host '] = = ' Www.vimeo.com ' | | $image _url[' host '] = = ' vimeo.com ') { $hash = unserialize (file_get_contents ("http://vimeo.com/api/v2/video/"). substr ($image _url[' path '], 1). ". PHP ")); return $hash [0]["Thumbnail_medium"];} }
Show YouTube video thumbnails and Vimeo video thumbnail code sharing