Skip to content

Instantly share code, notes, and snippets.

@sTiLL-iLL
Last active December 21, 2015 10:28
Show Gist options
  • Save sTiLL-iLL/6291915 to your computer and use it in GitHub Desktop.
Save sTiLL-iLL/6291915 to your computer and use it in GitHub Desktop.
Generate a embed widget on the fly!
//store the URL
var url = "http://vimeo.com/71673549";
//extract the ID
var rgx = /\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
//the ID: 71673549
var id = url.match(rgx);
var width = '640';
var height = '360';
//make embed code and wrap it
var $embd = $("<div id='myEmbed'/>")
.append('<div class="vimeo-article"><iframe src="http://player.vimeo.com/video/'+id+
'?title=0&byline=0&portrait=0&badge=0&color=ffffff" width="'+width+'" height="'+height+
'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>');
//write it to the page
$("body").append($embd).show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment