Skip to content

Commit

Permalink
Use highest available resolution for YouTube thumbnail image
Browse files Browse the repository at this point in the history
Prefer the following thumbnail resolutions in this order:
- maxres (1280x720)
- standard (640x480)
- high (480x360)
- medium (320x180)
- default (120x90)

See: https://developers.google.com/youtube/v3/docs/videos#snippet.thumbnails
  • Loading branch information
gg committed Feb 2, 2018
1 parent db872a8 commit bb83868
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions dist/lazyframe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lazyframe",
"version": "1.1.3",
"version": "1.1.4",
"description": "Dependency-free library for lazyloading iframes",
"main": "dist/lazyframe.min.js",
"jsnext:main": "src/lazyframe.js",
Expand Down
6 changes: 3 additions & 3 deletions src/lazyframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ const Lazyframe = () => {
youtube: {
title: (r) => r.items['0'].snippet.title,
thumbnail: (r) => {
let thumb = r.items["0"].snippet.thumbnails;
let url = thumb.maxres ? thumb.maxres.url : thumb.standard.url;
return url;
let thumbs = r.items["0"].snippet.thumbnails;
let thumb = thumbs.maxres || thumbs.standard || thumbs.high || thumbs.medium || thumbs.default;
return thumb.url;
}
},
vimeo: {
Expand Down

0 comments on commit bb83868

Please sign in to comment.