Skip to content

Instantly share code, notes, and snippets.

@leoherzog
Last active March 28, 2016 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoherzog/68cc9ae8eb6e37f8e464 to your computer and use it in GitHub Desktop.
Save leoherzog/68cc9ae8eb6e37f8e464 to your computer and use it in GitHub Desktop.
A drop-in piece of Javascript that will take an array of YouTube video IDs and embed them on the page
<script>
// Replace line below with video id(s)
// e.g. ["K0FdCdQItDI"]; or ["K0FdCdQItDI","8B3dpnUcMBY"];
//
//
var ids = ["K0FdCdQItDI"];
//
//
// Don't edit below
if (ids.length == 1) {
document.write("<iframe width=\"640px\" height=\"360px\" src=\"https://www.youtube.com/embed/" + ids + "?modestbranding=1&rel=0&autoplay=1\" frameborder=\"0\" allowfullscreen></iframe>");
document.write("<br />");
}
else {
for (var i = 0; i < ids.length; i++) {
document.write("<iframe width=\"640px\" height=\"360px\" src=\"https://www.youtube.com/embed/" + ids[i] + "?modestbranding=1&rel=0\" frameborder=\"0\" allowfullscreen></iframe>");
document.write("<br /> <br />");
};
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment