Custom Vimeo player for Tumblr

********
UPDATE 11/22/2010
This code has now been updated for the new vimeo embed code.
******** 

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>

  
  1. mdmanodyne reblogged this from alexhallajian
  2. katiepalmersketchbook reblogged this from alexhallajian
  3. thehurricanekid reblogged this from check-it
  4. check-it reblogged this from alexhallajian and added:
    And alter “var color = “55AAAA”;” to the embed color you desire....This code allows...
  5. alexhallajian posted this