alexhallajian - Custom Vimeo player for Tumblr
10 weeks ago by edmadrid
Based on Matthew Buchanan’s code. Just change the value for ‘newW’ and the vimeo player’s height will scale accordingly.
The script works with tubmlr themes that use jQuery and have post widths greater than 500px.
Add the below code to your theme. Change the value for newW to your desired vimeo player width.
<script type="text/javascript">
$(function() {
var color = "55AAAA";
$("iframe").each(function() {
var $obj = $(this);
var data = $obj.attr("data");
var vsrc = $obj.attr("src");
var oldW = $obj.attr("width");
var newW = 600;
var oldH = $obj.attr("height");
var p = oldW/newW;
var newH = (oldH / p);
if (vsrc.search("vimeo") > 0) {
$obj.replaceWith("<iframe src='"+vsrc+"?color="+color+"' width='"+newW+"' height='"+newH+"' frameborder='0'></iframe>");
}
});
})
</script>
javascript
vimeo
tumblr
The script works with tubmlr themes that use jQuery and have post widths greater than 500px.
Add the below code to your theme. Change the value for newW to your desired vimeo player width.
<script type="text/javascript">
$(function() {
var color = "55AAAA";
$("iframe").each(function() {
var $obj = $(this);
var data = $obj.attr("data");
var vsrc = $obj.attr("src");
var oldW = $obj.attr("width");
var newW = 600;
var oldH = $obj.attr("height");
var p = oldW/newW;
var newH = (oldH / p);
if (vsrc.search("vimeo") > 0) {
$obj.replaceWith("<iframe src='"+vsrc+"?color="+color+"' width='"+newW+"' height='"+newH+"' frameborder='0'></iframe>");
}
});
})
</script>
10 weeks ago by edmadrid