Created
December 15, 2017 11:15
-
-
Save Vyygir/29fcaca0263d86ce67b3e6f4c714454d to your computer and use it in GitHub Desktop.
Customise oembed fetching to pass arguments through to an alternate service
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 | |
/** | |
* Customise oembed fetching to pass arguments through to alternate services | |
*/ | |
add_filter('oembed_fetch_url', function($provider, $url, $args) { | |
if (strpos($provider, 'vimeo.com') !== false) { | |
if (isset($args['autoplay'])) { | |
$provider = add_query_arg('autoplay', absint($args['autoplay']), $provider); | |
} | |
if (isset($args['color']) && preg_match('/^[a-f0-9]{6}$/i', $args['color'])) { | |
$provider = add_query_arg('color', $args['color'], $provider); | |
} | |
if (isset($args['portrait'])) { | |
$provider = add_query_arg('portrait', absint($args['portrait']), $provider); | |
} | |
if (isset($args['title'])) { | |
$provider = add_query_arg('title', absint($args['title']), $provider); | |
} | |
if (isset($args['byline'])) { | |
$provider = add_query_arg('byline', absint($args['byline']), $provider); | |
} | |
} | |
return $provider; | |
}, 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment