pre_oembed_result
Filter HookDescription
Filters the oEmbed result before any HTTP requests are made. This allows one to short-circuit the default logic, perhaps by replacing it with a routine that is more optimal for your setup. Returning a non-null value from the filter will effectively short-circuit retrieval and return the passed value instead.Hook Information
File Location |
wp-includes/class-wp-oembed.php
View on GitHub
|
Hook Type | Filter |
Line Number | 408 |
Hook Parameters
Type | Name | Description |
---|---|---|
null|string
|
$result
|
The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null to continue retrieving the result. |
string
|
$url
|
The URL to the content that should be attempted to be embedded. |
string|array
|
$args
|
Optional. Additional arguments for retrieving embed HTML. See wp_oembed_get() for accepted arguments. Default empty. |
Usage Examples
Basic Usage
<?php
// Hook into pre_oembed_result
add_filter('pre_oembed_result', 'my_custom_filter', 10, 3);
function my_custom_filter($result, $url, $args) {
// Your custom filtering logic here
return $result;
}
Source Code Context
wp-includes/class-wp-oembed.php:408
- How this hook is used in WordPress core
<?php
403 * Default null to continue retrieving the result.
404 * @param string $url The URL to the content that should be attempted to be embedded.
405 * @param string|array $args Optional. Additional arguments for retrieving embed HTML.
406 * See wp_oembed_get() for accepted arguments. Default empty.
407 */
408 $pre = apply_filters( 'pre_oembed_result', null, $url, $args );
409
410 if ( null !== $pre ) {
411 return $pre;
412 }
413
PHP Documentation
<?php
/**
* Filters the oEmbed result before any HTTP requests are made.
*
* This allows one to short-circuit the default logic, perhaps by
* replacing it with a routine that is more optimal for your setup.
*
* Returning a non-null value from the filter will effectively short-circuit retrieval
* and return the passed value instead.
*
* @since 4.5.3
*
* @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
* Default null to continue retrieving the result.
* @param string $url The URL to the content that should be attempted to be embedded.
* @param string|array $args Optional. Additional arguments for retrieving embed HTML.
* See wp_oembed_get() for accepted arguments. Default empty.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/class-wp-oembed.php
Related Hooks
Related hooks will be displayed here in future updates.