YT Video Improvement: Change default API preview image quality

Hi,

Is there a possibility to change the default YouTube API preview image quality? Something like WP Rocket has: Choose YouTube preview image resolution - WP Rocket Knowledge Base

Thanks

3 Likes

UPDATE

I’ve checked the video element code and here is the part used for chosing the video thumbnail:

// STEP: Get YouTube video preview image from API
if ( $video_type === 'youtube' ) {
     return "https://img.youtube.com/vi/{$settings['youTubeId']}/hqdefault.jpg";
}

So, there is no way to change the thumbnail quality except editing the code directly.

It would be really handy to add there a possibility to change the quality. At least via filter, ideally in UI.

The simple filter could look something like this:

// STEP: Get YouTube video preview image from API
if ( $video_type === 'youtube' ) {
    $thumbnail_resolution = apply_filters( 'bricks/youtube_thumbnail_resolution', 'hqdefault' );
    return "https://img.youtube.com/vi/{$settings['youTubeId']}/{$thumbnail_resolution}.jpg";
}

And yes, I’m aware this could lead to possible issues, since some of the resolutions might not be available. If using the UI, there should be some info about it there.

I’m making this a feature request now. Thanks for considering it…