Skip to content

Instantly share code, notes, and snippets.

@OscarGodson
Last active December 19, 2015 03:59
Show Gist options
  • Save OscarGodson/5894071 to your computer and use it in GitHub Desktop.
Save OscarGodson/5894071 to your computer and use it in GitHub Desktop.
<script>
/**
* Version 1.1
* Makes Vimeo and YouTube videos on Tumblr larger than the max of 500px that Tumblr forces
* Change the 650 to whatever you want, but do NOT add px or %
* The height, by default, is set to auto which will calculate the 16:9 video size.
* You can set the height to a static number as well if you want.
* If you have any questions feel free to ask me: @oscargodson | oscargodson.com
*/
(function(){
var iframes = document.body.getElementsByTagName('iframe')
, newVimeoWidth = 650
, newVimeoHeight = 'auto';
for(x in iframes){
if(iframes[x].src && iframes[x].src.indexOf('player.vimeo.com') > -1 ||
iframes[x].src && iframes[x].src.indexOf('youtube.com') > -1){
if(newVimeoHeight == 'auto'){
newVimeoHeight = ( newVimeoWidth * 9 ) / 16;
}
iframes[x].width = newVimeoWidth;
iframes[x].height = newVimeoHeight
}
}
})();
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment