tylerpearson / lazyYT

A jQuery plugin to lazy load those dang Youtube iframe videos.
Other
208 stars 86 forks source link

maxresdefault and sddefault are not guaranteed to exist #45

Open jvanasco opened 9 years ago

jvanasco commented 9 years ago

This is a regression introduced by this ticket: https://github.com/tylerpearson/lazyYT/issues/12

I haven't been able to find any current YouTube docs, but "common knowledge" (as noted in this stack overflow post http://stackoverflow.com/a/20542029/442650) is that maxresdefault/sddefault only exist for videos that have been uploaded in high definition.

The way the plugin is currently coded, it will try to embed these non-existent images. the result is that

Here's an example with an older movie trailer that was not uploaded in HD:

The only way to tell if maxresdefault or sddefault exists is to query the API. This library should either max out on the hqdefault image size (never use maxresdefault or sddefault) or query the API to decide if they should be used. Unfortunately the current behavior of the library makes some content look great, and the rest look absolutely terrible.

Daugilas commented 8 years ago

Solved with commit: https://github.com/Daugilas/lazyYT/commit/a7f02270d2c1d0e20916fb44489d4d095c78b373

Latest version here: https://github.com/Daugilas/lazyYT/