CODE CODIFY.CLUB

Removing black borders on youtube thumbnails

YouTube offers images that don’t have the 4:3 ratio black strips. To get a 16:9 video thumbnail with no black strips, try one of these:


http://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg

http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg



For other YouTube thumbnail option you can use following.

https://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg

==================

Get Video ID in WordPress

$video_link = get_field(‘youtube_video’,get_the_ID()); 

if (preg_match(‘%(?:youtube(?:-nocookie)?.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu.be/)([^”&?/ ]{11})%i’, $video_link, $match)){
    $video_id = $match[1];
}

V!ral

Developer, Technology aficionado, Beer Lover and founder of codify.club Network. Who shares a keen interest about website development, health issues, cancer awareness and other fun stuff.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed