How to get image from youtube and vimeo embedded url?

This tutorial for gettting the image from youtube and vimeo embedded url using the php code without any 3rd party tools. you can just enter the embedded url in below code and get HD Image from this two plateform

Step 1)

just put this code in your php file where you want to get the youtube and vimeo embedded url image in high resolution.

$url2 = "Your youtube and vimeo embedded url here";
$parsed     = parse_url($url2);
$hostname   = $parsed['host']; 
$path       = $parsed['path']; 
if(!empty($hostname)){
  if($hostname=='www.youtube.com' || $hostname=='youtube.com'){
	preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url2, $match);
	$youtube_id = $match[1];
        $videoID = substr($youtube_id,0,11);
        $video_image_src = "https://i.ytimg.com/vi/".$videoID."/maxresdefault.jpg";
	$video_image_href = "https://www.youtube.com/embed/".$videoID;
}else if($hostname=='player.vimeo.com'){
	preg_match("/vimeo\.com\/(\w+\s*\/?)*([0-9]+)*$/i", $url2, $output_array);
	$vimdeoIDInt = intval($output_array[1]);
	$vimeo = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$vimdeoIDInt.php"));
	$small = $vimeo[0]['thumbnail_small'];
	$medium = $vimeo[0]['thumbnail_medium'];
	$large = $vimeo[0]['thumbnail_large'];
        $video_image_src = $large;
	$video_image_href = "https://player.vimeo.com/video/".$vimdeoIDInt; 
 }
echo $video_image_href;
}

4 thoughts on “How to get image from youtube and vimeo embedded url?

  1. tempmail

    I do not even know how I ended up here but I thought this post was great I dont know who you are but definitely youre going to a famous blogger if you arent already Cheers.

    Reply
  2. zencortex reviews

    This website has quickly become my go-to source for [topic]. The content is consistently top-notch, covering diverse angles with clarity and expertise. I’m constantly recommending it to colleagues and friends. Keep inspiring us!

    Reply
  3. Temp mail

    Your work has captivated me just as much as it has captivated you. The visual presentation is elegant, and the written content is sophisticated. However, you appear concerned about the possibility of presenting something that could be considered dubious. I’m confident you’ll be able to resolve this issue promptly.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *