Result
jQuery
$(".vimeo-thumb").each(function(){ var id = $(this).data('vimeoid'); //JSONを取得してIDを代入 $.getJSON('http://www.vimeo.com/api/v2/video/' + id + '.json?callback=?', {format: "json"}, function(data) { //.vimeo***というclassのDOMに背景としてサムネイルを指定 $('.vimeo' + id).css('background-image', 'url("' + data[0].thumbnail_medium + '")'); }); });
css
.vimeo-thumb { background: #fff url(foo.gif) }
html
<img alt="Vimeo" class="vimeo-thumb vimeovimeoの動画ID" data-vimeoid="vimeoの動画ID" src="foo.gif">
via
https://forrst.com/posts/Vimeo_thumbnails_dynamically_with_Javascript-w5j