Skip to content

Instantly share code, notes, and snippets.

@lyatziv
Created July 12, 2013 07:23
Show Gist options
  • Save lyatziv/5982560 to your computer and use it in GitHub Desktop.
Save lyatziv/5982560 to your computer and use it in GitHub Desktop.
A quick way to load a bunch of videos from vimeo.
jQuery(document).ready(function($){
$('iframe[src*="player.vimeo"]').each(function(){
var id = $(this).attr("src").split("/").slice(-1)[0];
$(this).addClass("video_id_"+id);
$(this).parent().addClass("vimeo_id_"+id);
$.ajax({
type:'GET',
url: 'http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/' + id +'.json',
jsonp: 'callback',
dataType: 'jsonp',
success: function(data){
$(".vimeo_id_"+id).append("<img class='lazy_vimeo' data-object='" + JSON.stringify(data) + "' src='" + data.thumbnail_url + "'/>");
$(".video_id_"+id).remove();
$(".lazy_vimeo").each(function(){
$(this).click(function(){
var data = $.parseJSON($(this).attr("data-object"));
$(this).parent().append(data.html);
$(this).remove();
});
});
}
});
});
});
@davidooo
Copy link

If any help, here is the page:
http://davidortiz.es/c/unseen/videos.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment