Last active
December 17, 2015 20:38
-
-
Save davefowler/5668548 to your computer and use it in GitHub Desktop.
Javascript snippet to get youtube code and thumbnail of a youtube video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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