Last active
June 16, 2016 22:22
-
-
Save johndigital/2c050f7e734330256b04 to your computer and use it in GitHub Desktop.
Override Wordpress oembed defaults for Vimeo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Override default vimeo oembed behavior | |
*/ | |
function set_vimeo_defaults(){ | |
// set vimeo oembed args | |
// see full list here: developer.vimeo.com/apis/oembed | |
$args = array( | |
'color' => 'ffffff', | |
'title' => false, | |
'portrait' => false, | |
'byline' => false, | |
'api' => true, | |
'player_id' => uniqid() | |
); | |
// set regex and oembed url | |
$provider_regex = '#https?://(.+\.)?vimeo\.com/.*#i'; | |
$oembed_source = 'http://vimeo.com/api/oembed.{format}?' . http_build_query($args); | |
// override the default vimeo configuration | |
return wp_oembed_add_provider( $provider_regex, $oembed_source, true ); | |
} | |
add_action('init', 'set_vimeo_defaults'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is where I ended up, works great:
And the JS: