Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Customise oembed fetching to pass arguments through to an alternate service
<?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
You can’t perform that action at this time.