Skip to content

OEmbeds that return html missing the closing </iframe> tag do not render properly in the editor #34860

Closed

Description

@AetherUnbound

Description

This forum post best describes the issue and resolution: https://wordpress.org/support/topic/embed-size-is-stuck-at-zero/

Summarized, if an oembed API returns an html field that contains an iframe tag that does not have a closing </iframe>, it will not be rendered in the editor (although once published, it will be rendered fine).

Step-by-step reproduction instructions

  1. Add a oembed provider which returns html that is missing a closing </iframe>
  2. Create a page
  3. Add an embedded block using a URL that matches the oembed provider created in step 1
  4. Click "embed" (the block should mostly disappear)

Screenshots, screen recording, code snippet

Current behavior

Screenshot_2021-09-15_16-46-58

Expected behavior

Screenshot_2021-09-15_16-47-16

Environment info

WordPress version: 5.8.1 or 5.9-alpha-51806
Gutenberg version: 11.5.0-rc.1 (possibly more)

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

  1. added
    Needs Testing
    on Sep 24, 2021
  2. added
    [Block] HTML
    on Apr 28, 2022
  3. removed
    Needs Testing
    on Aug 10, 2022
  4. added
    [Type] Bug
    [Block] Embed
    on Sep 14, 2023
  5. t-hamano commented on Sep 17, 2026

    @t-hamano
    Contributor

    Sorry for the late reply. This issue has likely been resolved by #79920. I added a provider that returns a response without a closing iframe tag as shown below, but the iframe still renders with the correct width and height.

    wp_oembed_add_provider(
    	'https://embed-test.example/*',
    	'https://embed-test.example/oembed'
    );
    
    add_filter(
    	'pre_http_request',
    	function ( $response, $args, $url ) {
    		if ( 0 !== strpos( $url, 'https://embed-test.example/oembed?' ) ) {
    			return $response;
    		}
    
    		return array(
    			'headers'  => array(),
    			'body'     => wp_json_encode(
    				array(
    					'version' => '1.0',
    					'type'    => 'rich',
    					'html'    => '<iframe width="480" height="160" srcdoc="Embed test">',
    				)
    			),
    			'response' => array( 'code' => 200, 'message' => 'OK' ),
    			'cookies'  => array(),
    			'filename' => null,
    		);
    	},
    	10,
    	3
    );
    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] Embed[Block] HTML[Type] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions