-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.fixvimeo.js
45 lines (43 loc) · 1.33 KB
/
jquery.fixvimeo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Better Vimeo Embeds 2.2 by Matthew Buchanan
* Modelled on the Vimeo Embedinator Script
* http://mattbu.ch/tumblr/vimeo-embeds/
*
* Released under the WTFPL license
* http://sam.zoy.org/wtfpl/
*
* First released July 14, 2009
*/
(function($) {
$.fn.fixVimeo = function(hexColor) {
var color = hexColor.split("#")[1];
var opts = "title=0&byline=0&portrait=0";
return this.each(function() {
var $posts = $(this);
$posts.find("iframe[src*='//player.vimeo.com']").each(function() {
var src = $(this).attr("src");
var w = $(this).attr("width");
var h = $(this).attr("height");
if (src.indexOf("?") === -1) {
$(this).replaceWith("<iframe src='" + src
+ "?" + opts + "&color=" + color
+ "' width='" + w + "' height='" + h
+ "' frameborder='0'></iframe>");
}
});
$posts.find("object[data*='//vimeo.com']").each(function() {
var $obj = $(this);
var data = $obj.attr("data");
var temp = data.split("clip_id=")[1];
var id = temp.split("&")[0];
var server = temp.split("&")[1];
var w = $obj.attr("width");
var h = $obj.attr("height");
$obj.replaceWith("<iframe src='//player.vimeo.com/video/" + id
+ "?" + server + "&" + opts + "&color=" + color
+ "' width='" + w + "' height='" + h
+ "' frameborder='0'></iframe>");
});
});
}
})(jQuery);