yanknudtskov
8/24/2017 - 1:22 PM

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';
}