diff --git src/wp-includes/embed.php src/wp-includes/embed.php
index d961dc941b..7efad22401 100644
--- src/wp-includes/embed.php
+++ src/wp-includes/embed.php
@@ -1065,6 +1065,32 @@ function the_embed_site_title() {
  *                     Null if the URL does not belong to the current site.
  */
 function wp_filter_pre_oembed_result( $result, $url, $args ) {
+	if ( is_multisite() ) {
+		$url_parts = wp_parse_args( parse_url( $url ), array(
+			'host'   => '',
+			'path'   => '/',
+		) );
+
+		$qv = array( 'domain' => $url_parts['host'], 'path' => '/' );
+
+		// In case of subdirectory configs, set the path.
+		if ( ! is_subdomain_install() ) {
+			$path = explode( '/', ltrim( $url_parts['path'], '/' ) );
+			$path = reset( $path );
+
+			if ( $path ) {
+				$qv['path'] = get_network()->path . $path . '/';
+			}
+		}
+
+		$sites = get_sites( $qv );
+		$site  = reset( $sites );
+
+		if ( $site && (int) $site->blog_id !== (int) get_current_blog_id() ) {
+			switch_to_blog( $site->blog_id );
+		}
+	}
+
 	$post_id = url_to_postid( $url );
 
 	/** This filter is documented in wp-includes/class-wp-oembed-controller.php */
@@ -1079,6 +1105,10 @@ function wp_filter_pre_oembed_result( $result, $url, $args ) {
 	$data = get_oembed_response_data( $post_id, $width );
 	$data = _wp_oembed_get_object()->data2html( (object) $data, $url );
 
+	if ( is_multisite() && ms_is_switched() ) {
+		restore_current_blog();
+	}
+
 	if ( ! $data ) {
 		return $result;
 	}
diff --git tests/phpunit/tests/oembed/wpOembed.php tests/phpunit/tests/oembed/wpOembed.php
index ade91df95e..4499e81088 100644
--- tests/phpunit/tests/oembed/wpOembed.php
+++ tests/phpunit/tests/oembed/wpOembed.php
@@ -69,4 +69,106 @@ class Tests_WP_oEmbed extends WP_UnitTestCase {
 		$this->assertNotFalse( $this->pre_oembed_result_filtered );
 		$this->assertFalse( $actual );
 	}
+
+	/**
+	 * @ticket 40673
+	 * @group multisite
+	 * @group ms-required
+	 */
+	public function test_wp_filter_pre_oembed_result_multisite_root_root() {
+		$post_id   = self::factory()->post->create();
+		$permalink = get_permalink( $post_id );
+
+		add_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
+		$actual = $this->oembed->get_html( $permalink );
+		remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
+
+		$this->assertNotNull( $this->pre_oembed_result_filtered );
+		$this->assertEquals( $this->pre_oembed_result_filtered, $actual );
+	}
+
+	/**
+	 * @ticket 40673
+	 * @group multisite
+	 * @group ms-required
+	 */
+	public function test_wp_filter_pre_oembed_result_multisite_sub_samesub() {
+		$user_id = self::factory()->user->create();
+
+		$blog_id = self::factory()->blog->create( array(
+			'user_id' => $user_id,
+		) );
+
+		switch_to_blog( $blog_id );
+
+		$post_id   = self::factory()->post->create();
+		$permalink = get_permalink( $post_id );
+
+		add_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
+		$actual = $this->oembed->get_html( $permalink );
+		remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
+
+		restore_current_blog();
+
+		$this->assertNotNull( $this->pre_oembed_result_filtered );
+		$this->assertEquals( $this->pre_oembed_result_filtered, $actual );
+	}
+
+	/**
+	 * @ticket 40673
+	 * @group multisite
+	 * @group ms-required
+	 */
+	public function test_wp_filter_pre_oembed_result_multisite_sub_othersub() {
+		$user_id = self::factory()->user->create();
+
+		$blog_id = self::factory()->blog->create( array(
+			'user_id' => $user_id,
+		) );
+
+		switch_to_blog( $blog_id );
+
+		$post_id   = self::factory()->post->create();
+		$permalink = get_permalink( $post_id );
+
+		$blog_id = self::factory()->blog->create( array(
+			'user_id' => $user_id,
+		) );
+
+		switch_to_blog( $blog_id );
+
+		add_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
+		$actual = $this->oembed->get_html( $permalink );
+		remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
+
+		restore_current_blog();
+
+		$this->assertNotNull( $this->pre_oembed_result_filtered );
+		$this->assertEquals( $this->pre_oembed_result_filtered, $actual );
+	}
+
+	/**
+	 * @ticket 40673
+	 * @group multisite
+	 * @group ms-required
+	 */
+	public function test_wp_filter_pre_oembed_result_multisite_sub_main() {
+		$post_id   = self::factory()->post->create();
+		$permalink = get_permalink( $post_id );
+		$user_id   = self::factory()->user->create();
+		$blog_id   = self::factory()->blog->create( array(
+			'user_id' => $user_id,
+		) );
+
+		switch_to_blog( $blog_id );
+
+		add_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
+		$actual = $this->oembed->get_html( $permalink );
+		remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
+
+		restore_current_blog();
+
+		$this->assertNotNull( $this->pre_oembed_result_filtered );
+		$this->assertEquals( $this->pre_oembed_result_filtered, $actual );
+	}
 }
