The thumbnails looked fine for over a year, but suddenly became blurry. The thumbnail that appears on page load looks correct, but anytime a new thumbnail is displayed using 'player.cueVideoById', it looks very blurry.
There is no mention in the documentation of how to control the thumbnail quality (only video quality settings, such as 'setPlaybackQuality' are available). The documentation: https://developers.google.com/youtube/iframe_api_reference
How can I force high quality thumbnail images?
Yes, this issue is easily reproducible. I've created a slightly modified version of the documentation example, it loads a video and calls
setPlaybackQuality
a second later. It is clearly visible that the quality decreases. In fact, the original thumbnail ishttps://i.ytimg.com/vi/M7lc1UVf-VE/sddefault.jpg
, it is being replaced byhttps://i1.ytimg.com/vi/M7lc1UVf-VE/default.jpg
.While the Flash player is pretty opaque, for the HTML5 player we can take a look at the (pretty obfuscated) source code. This piece of code is particularly interesting (reformatted for readability):
This indicates that you are indeed not supposed to control thumbnail quality, it is rather set according to viewport size. If width exceeds 900 or height exceeds 600 you get
maxresdefault.jpg
, if width exceeds 430 or height exceeds 320 you getsddefault.jpg
and in all the remaining cases you getdefault.jpg
. This works like that indeed - for the initial load. And this seems to be the intended behavior.However, that's not what you get for
player.cueVideoById()
- there it is alwaysdefault.jpg
,presumably because. Edit: Actually, debugging the code has shown thata.j
is set (whatever that might be)a.j
isn't the culprit here. Instead, theAv
function returnsundefined
when called for anything other than"default.jpg"
because the data structures (b.La
map in particular) aren't completely initialized. To me, this simply looks like a bug, and it seems that it was already reported to Google.For reference, the source code of function
Av
:Mt(a.videoId, b)
would return the correct URL but the function returnsc
instead meaningundefined
.Note that the text above applies only to the HTML5 player. Behavior of the Flash player is slightly different and similarly inconsistent.