How to get image from youtube and vimeo embedded url?
This tutorial is for getting the image from YouTube and Vimeo embedded URLs using the PHP code without any 3rd party tools. You can just enter the embedded URL in the below code and get an HD image from these two platforms.
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;
}
I am sure this piece of writing has touched all the internet visitors, its really really nice post on building up new website.
Wow, this article is good, my younger sister is analyzing these things, therefore I am going to tell her.
You completed a number of fine points there. I did a search on the subject matter and found nearly all folks will go along with with your blog.
You have made some good points there. I checked on the web for more information about the issue and found most individuals will go along with your views on this web site.
August 3rd: The ROBLOX catalog and all different forms of ROBLOX financial system had been restored around 9 p.m. EST.
Ahaa, its nice conversation concerning this piece of writing here at this blog, I have read all that, so at this time me also commenting here.
it!|