Youtube Vimeo programming

<?php
 
  $url= 'http://vimeo.com/59026775';          
$url= 'https://youtu.be/wByp5d4IutM';
$url = 'https://www.youtube.com/watch?v=SbGFYjCbpRs';

$type = getTypeByURL($url);
$code = getCodeByURL($url);

$size ='';
if($type == 'youtube'){
    $size = 0;
}else{
    $size = 'large';
}

$thumbnail_url = getThumbnailByVideoURL($code, $type, $size);

function getTypeByURL($url){

    if(strstr($url, 'v=') || strpos($url, 'youtube.com') || strpos($url, 'youtu.be')){
        $type = 'youtube';
    }elseif(strpos($url, 'vimeo.com')){
        $type = 'vimeo';
    }
    return $type;
}

function getCodeByURL($url){

    if(strstr($url, 'v=')){
        $queryString = parse_url($url, PHP_URL_QUERY);
        parse_str($queryString, $params);
        $code = $params['v'];
    }else{
        $video_explode = explode('/', $url);
        $code = $video_explode[sizeof($video_explode)-1];
    }

    return $code;
}


function getThumbnailByVideoURL($code, $type = '', $size = ''){
    $thumbnail_url = '';
     if($type =='youtube'){
         $thumbnail_url = "https://i3.ytimg.com/vi/".$code."/".$size.".jpg";
     }elseif($type =='vimeo'){
         $thumbnail_info = unserialize(file_get_contents("https://vimeo.com/api/v2/video/$code.php"));
         if(!empty($thumbnail_info)){
             $thumbnail_url = $thumbnail_info[0]['thumbnail_'.$size];
         }
     }
    return $thumbnail_url;
}

    ?>
    <iframe width="750" height="400" src="https://www.youtube.com/embed/<?php echo $code; ?>" frameborder="0" allowfullscreen></iframe>

<iframe src="https://player.vimeo.com/video/189483103" width="640" height="1138" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
   
   
function showVideo(code){
jQuery('#video_frame').html('<iframe width="750" height="400" src="https://www.youtube.com/embed/'+code+'" frameborder="0" allowfullscreen></iframe>');
jQuery('.vimeo_video_wrapper').show();
jQuery('.close_video').show();
}
function closeVideo(){
jQuery('#video_frame').html('');
jQuery('.vimeo_video_wrapper').hide();
jQuery('.close_video').hide();
}

<div class="play_icon"><a href="javascript:" onclick="showVideo('<?php echo $video_code; ?>')">Play</a></div>
                        <img src="<?php echo $thumb; ?>" title="<?php echo $video->title; ?>" alt="<?php echo $video->title; ?>">

.vimeo_video_wrapper{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
z-index: 555;
display: none;
}
.vimeo_video_container{
left: 50%;
margin: -200px auto 0 -375px;
position: fixed;
top: 50%;
width: 750px;
z-index: 5000;
}
.vimeo_video_container .close_video{
position:absolute;
z-index:500;
right:-16px;
top:-16px;
}