wp_filter_pre_oembed_result() WordPress Function

The wp_filter_pre_oembed_result() function was introduced in WordPress 4.4. It allows for the modification of the oEmbed HTML before it is passed to the oEmbed provider.

wp_filter_pre_oembed_result( null|string $result, string $url, array $args ) #

Filters the oEmbed result before any HTTP requests are made.


Description

If the URL belongs to the current site, the result is fetched directly instead of going through the oEmbed discovery process.


Top ↑

Parameters

$result

(null|string)(Required)The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.

$url

(string)(Required)The URL that should be inspected for discovery <link> tags.

$args

(array)(Required)oEmbed remote get arguments.


Top ↑

Return

(null|string) The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Null if the URL does not belong to the current site.


Top ↑

Source

File: wp-includes/embed.php

function wp_filter_pre_oembed_result( $result, $url, $args ) {
	$data = get_oembed_response_data_for_url( $url, $args );

	if ( $data ) {
		return _wp_oembed_get_object()->data2html( $data, $url );
	}

	return $result;
}


Top ↑

Changelog

Changelog
VersionDescription
4.5.3Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.