pre_oembed_result

Filters the oEmbed result before any HTTP requests are made.

Description

apply_filters( 'pre_oembed_result', (null) $null, (string) $url, (array) $args ); 

This allows one to short-circuit the default logic, perhaps by replacing it with a routine that is more optimal for your setup.

Passing a non-null value to the filter will effectively short-circuit retrieval, returning the passed value instead.

Parameters (3)

0. $null (null) => null
The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.
1. $url (string)
The URL to the content that should be attempted to be embedded.
2. $args — Optional. (array)
Arguments, usually passed from a shortcode. Default empty.

Usage

To run the hook, copy the example below.
  1. $null = apply_filters( 'pre_oembed_result', $null, $url, $args ); 
  2.  
  3. if ( !empty( $null ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the pre_oembed_result callback 
  2. function filter_pre_oembed_result( $null, $url, $args ) { 
  3. // make filter magic happen here... 
  4. return $null
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'pre_oembed_result', 'filter_pre_oembed_result', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'pre_oembed_result', 'filter_pre_oembed_result', 10, 3 ); 

Defined (2)

The filter is defined in the following location(s).

/wp-includes/class-oembed.php  
  1. $pre = apply_filters( 'pre_oembed_result', null, $url, $args ); 
/wp-includes/default-filters.php  
  1. add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 );