Created
July 16, 2013 11:32
-
-
Save ktroye/6007946 to your computer and use it in GitHub Desktop.
Javascript: Embed Youtube
This file contains hidden or 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
| function embedYoutube(link, ops) { | |
| var o = $.extend({ | |
| width: 480, | |
| height: 320, | |
| params: '' | |
| }, ops); | |
| var id = /\?v\=(\w+)/.exec(link)[1]; | |
| return '<iframe style="display: block;"'+ | |
| ' class="youtube-video" type="text/html"'+ | |
| ' width="' + o.width + '" height="' + o.height + | |
| ' "src="http://www.youtube.com/embed/' + id + '?' + o.params + | |
| '&wmode=transparent" frameborder="0" />'; | |
| } | |
| embedYoutube( | |
| 'https://www.youtube.com/watch?v=JaAWdljhD5o', | |
| { params: 'theme=light&fs=0' } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment