oEmbed vimeo with add_query_arg parameters not inserted to HTML

Take out the var_dump. That is debugging code, it’s dumping the variable so that you can see what it is.

Edit: Okay, I think you’re asking the wrong question here, as did the other person in the question that you linked to.

Adding additional query args onto the URL being sent to wp_ombed_url() won’t cause the oembed system to send them on to the oembed provider endpoint. You need to add them as arguments to the provider, not as arguments to the URL that you’re requesting to be embedded.

You would need to use a filter to add the parameters to the actual oembed request, not to the URL parameter. Like so:

add_filter('oembed_fetch_url','example_add_vimeo_args',10,3);
function example_add_vimeo_args($provider, $url, $args) {
    if ( strpos($provider, '//vimeo.com/') !== false ) {
        $args = array(
            'title' => 0,
            'byline' => 0,
            'portrait' => 0,
            'badge' => 0
        );
        $provider = add_query_arg( $args, $provider );
    }
    return $provider;   
}

See, the URL is the URL of the video that you want to be embedded. WordPress contacts that provider’s oembed endpoint to get the embed code for that video. If you want to change the response from that endpoint, then you have to change the arguments to the endpoint, not the arguments to the URL it’s asking about.

Leave a Comment