youtub link find image

0
329

Exmp : https://www.youtube.com/embed/qGBV2eQrRwA

https://img.youtube.com/vi//0.jpg
https://img.youtube.com/vi//1.jpg
https://img.youtube.com/vi//2.jpg
https://img.youtube.com/vi//3.jpg
https://img.youtube.com/vi//default.jpg
https://img.youtube.com/vi//hqdefault.jpg
https://img.youtube.com/vi//mqdefault.jpg
https://img.youtube.com/vi//sddefault.jpg

function getYouTubeIdFromURL($url)
{
$pattern = ‘~(?:youtube.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu.be/)([^”&?/ ]{11})~i’;
preg_match($pattern, $url, $matches);
return isset($matches[1]) ? $matches[1] : false;
}
$embed_code_id = getYouTubeIdFromURL($_POST[’embeded_code’]);