Created
July 18, 2012 22:30
-
-
Save keenahn/3139373 to your computer and use it in GitHub Desktop.
Create a youtube iframe using jQuery
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
jQuery -> | |
window.youtube_iframe = (video_id, args) -> | |
default_options = { | |
width: 853 | |
height: 480 | |
autoplay: 0 | |
rel: 0 | |
class: "youtube-video" | |
frameborder: "0" | |
allowfullscreen: true | |
} | |
options = $.extend(false, default_options, args) | |
options.src = "http://www.youtube.com/embed/" + video_id + "?rel=" + options.rel + "&autoplay=" + options.autoplay | |
ret = $(document.createElement "iframe") | |
ret.attr options | |
return ret |
TODO: add support for all the options detailed here: http://brianwong.com/blog/2012-youtube-embed-code-autoplay-on-and-all-other-parameters/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Return value is ready to be appended or prepended to your jQuery objects.