If I embed something with oEmbed, is there a chance to get the type of the embed (video, audio etc.) ?

If I look at www.oembed.com I see that in the JSON response there is always the data type.

Any chance to get this without hacking the core?

I don’t find any functions, except wp_oembed_get, which seems to only return the width and height.

1 Answer
1

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.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *