oEmbed, thumbnails and wordpress

Use the oembed_dataparse filter to modify the resulting HTML output by any given oembed call.

Example:

add_filter('oembed_dataparse','test',10,3);

function test($return, $data, $url) {
    if ($data->provider_name == 'YouTube') {
        return "<img src="https://wordpress.stackexchange.com/questions/79894/{$data->thumbnail_url}">";
    }
    else return $return;
}

Then putting this in a post:


Will give you a picture of Rick Astley instead of a flash video of him. 🙂

Edit: Note that WordPress caches oEmbed results in postmeta. So after making your code, you’ll have to go and Update a post for it to know to go re-get the oEmbed data and have code like this take effect. In case you want to do testing and such.