Save this code in empty .php file and test it.
<img src="<?php echo youtube_img_src('9bZkp7q19f0', 'high');?>" />
<?php
// Get a YOUTUBE video thumb image's source url for IMG tag "src" attribute:
// $ID = YouYube video ID (string)
// $size = string (default, medium, high or standard)
function youtube_img_src ($ID = null, $size = 'default') {
switch ($size) {
case 'medium':
$size = 'mqdefault';
break;
case 'high':
$size = 'hqdefault';
break;
case 'standard':
$size = 'sddefault';
break;
default:
$size = 'default';
break;
}
if ($ID) {
return sprintf('https://img.youtube.com/vi/%s/%s.jpg', $ID, $size);
}
return 'https://img.youtube.com/vi/ERROR/1.jpg';
}
Thanks.