How to get the oEmbed type (audio, video, image etc.)?

I wonder if you mean this:

add_filter( 'oembed_dataparse', function( $return, $data, $url )
{
    // Target only 'video' type:
    if(
            is_object( $data ) 
        &&  property_exists( $data, 'type' )
        &&  'video' === $data->type
    )
    {
        // do stuff
    }
    return $return;
}, 10, 3 );

where we target the video type response from the oEmbed service, before it’s cached in the post meta.

Leave a Comment