YouTube embed handler callback.

Catches URLs that can be parsed but aren’t supported by oEmbed.

Signature

wp_embed_handler_youtube( $matches, $attr, $url, $rawattr )
matches
 (array) The regex matches from the provided regex when calling
attr
 (array) Embed attributes.
url
 (string) The original URL that was matched by the regex.
rawattr
 (array) The original unmodified attributes.

Return

(string) The embed HTML.

Source

function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
	global $wp_embed;
	$embed = $wp_embed->autoembed( "https://youtube.com/watch?v={$matches[2]}" );
	/**
	 * Filter the YoutTube embed output.
	 *
	 * @since 4.0.0
	 *
	 * @see wp_embed_handler_youtube()
	 *
	 * @param string $embed   YouTube embed output.
	 * @param array  $attr    An array of embed attributes.
	 * @param string $url     The original URL that was matched by the regex.
	 * @param array  $rawattr The original unmodified attributes.
	 */
	return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr );
}
WP Trac GitHub

Link here