Skip to content

Instantly share code, notes, and snippets.

@davefowler
Last active December 17, 2015 20:38
Show Gist options
  • Save davefowler/5668548 to your computer and use it in GitHub Desktop.
Save davefowler/5668548 to your computer and use it in GitHub Desktop.
Javascript snippet to get youtube code and thumbnail of a youtube video
var youtubelink = $('object param[name="movie"]').val(); // grabs the video link from an embedded video
// OLD EMBED STYLE CODE var youtubecode = youtubelink.match(/\/v\/(.*)\?/)[1];
var youtubecode = youtubelink.match(/\/embed\/(.*)/)[1];
var pinimage = 'http://img.youtube.com/vi/' + youtubecode + '/0.jpg';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment