yan-k
9/22/2017 - 8:27 AM

Getting YouTube Preview Image

Getting YouTube Preview Image

<?php

function get_youtube_preview_image( $url ) {
    $vars = array();
    parse_str( parse_url( $url, PHP_URL_QUERY ), $vars );
    return 'https://img.youtube.com/vi/'.$vars['v'].'/hqdefault.jpg';
}