Better Vimeo embeds on Tumblr

Note: an updated version of this function with support for Vimeo’s universal player is detailed in this post.

Vimeo offers plenty of customisation options when embedding its player, but Tumblr’s automated code generator doesn’t respect these, overwriting them with its own defaults. To fix this, I wrote a quick jQuery function to rewrite Tumblr’s default options string for all Vimeo embeds on the current page (get the ready-to-install version):

$("object[data^='http://vimeo.com']").each(function() {
    var parent = $(this).parent();
    var vimeoCode = parent.html();
    var params = "";
    if (vimeoCode.toLowerCase().indexOf("<param") == -1) {
        $("param", this).each(function() {
            params += $(this).get(0).outerHTML;
        });
    }
    var oldOpts = /show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF/g;
    var newOpts = "show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=55CC55";
    vimeoCode = vimeoCode.replace(oldOpts, newOpts);
    if (params != "") {
        params = params.replace(oldOpts, newOpts);
        vimeoCode = vimeoCode.replace(/<embed/i, params + "<embed");
    }
    parent.html(vimeoCode);
});

Tweak the newOpts string to whatever you prefer — it will work for all embeds except those that have had their options locked by their respective owners. You can see it in action here.

Update: IE mangles the <object> tag when returning it as an HTML string. I’ve updated the code to make it work as intended.

Written and designed by Matthew Buchanan. Colophon. Please give credit. Email me.