-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjquery-vimeothumb.min.js
10 lines (10 loc) · 1.08 KB
/
jquery-vimeothumb.min.js
1
2
3
4
5
6
7
8
9
10
/*!
* jQuery VimeoThumb
* Automatically replace image src with vimeo thumbnail url.
* Original author: Juan Pablo Garcia
* version: 1.0.0 (Wed, 14 Aug 2013)
* Further changes, comments: @jpgd
* Source Code: https://github.com/Ideame/jquery-vimeothumb
* Licensed under the MIT license
*/
;(function(e,c,a,g){var d="VimeoThumb",f={idSelectorName:"data-vimeo-id",vimeoPatternUrl:"http://vimeo.com/api/v2/video/%id.json?callback=?"};function b(i,h){this.elements=i;this.options=e.extend({},f,h);this._defaults=f;this._name=d;this.init()}b.prototype={init:function(){var h=this.options;e(this.elements).each(function(k,l){var m=e(l).attr(h.idSelectorName);if(m&&!/VIMEO/i.test(e(l).attr("src"))){var j=h.vimeoPatternUrl.replace(/%id/,m);e.getJSON(j,function(i){if(i[0]){if(e(l).hasClass("large")){e(l).attr("src",i[0].thumbnail_large)}else{if(e(l).hasClass("small")){e(l).attr("src",i[0].thumbnail_small)}else{e(l).attr("src",i[0].thumbnail_medium)}}}})}})}};e.fn[d]=function(h){return this.each(function(){if(!e.data(this,"plugin_"+d)){e.data(this,"plugin_"+d,new b(this,h))}})}})(jQuery,window,document);