This article mainly introduces the code for displaying youtube video thumbnails and Vimeo video thumbnails. For more information, see
The code is as follows:
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"];
}
}
"/>