get the thumbnail of the you tube url

function get_youtube_thumb($link,$type){

    $video_id = explode("?v=", $link); 
        if (empty($video_id[1])){
           $video_id = explode("/v/", $link); 
           $video_id = explode("&", $video_id[1]); 
           $video_id = $video_id[0];
        }
    $thumb_link = "";
    if($type == 'default' || $type == 'hqdefault' || $type == 'mqdefault' || $type == 'sddefault' || $type == 'maxresdefault'){

        $thumb_link = 'http://img.youtube.com/vi/'.$video_id.'/'.$type.'.jpg';

    }elseif($type == "id"){
        $thumb_link = $video_id;
    }
    return $thumb_link;
 }

Comments

Popular posts from this blog

Enable the imap in support in xampp server