Embeds: After [37745], check if a featured image exists before attaching an event listener.

Props swissspidy.
Fixes #35657.

git-svn-id: https://develop.svn.wordpress.org/trunk@37977 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling 2016-07-05 16:15:05 +00:00
parent 146e6665c8
commit 9037072780
1 changed files with 6 additions and 3 deletions

View File

@ -26,6 +26,7 @@
share_dialog_close = document.querySelector( '.wp-embed-share-dialog-close' ), share_dialog_close = document.querySelector( '.wp-embed-share-dialog-close' ),
share_input = document.querySelectorAll( '.wp-embed-share-input' ), share_input = document.querySelectorAll( '.wp-embed-share-input' ),
share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ), share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ),
featured_image = document.querySelector( '.wp-embed-featured-image img' ),
i; i;
if ( share_input ) { if ( share_input ) {
@ -139,9 +140,11 @@
sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) ); sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
// Send the document's height again after the featured image has been loaded. // Send the document's height again after the featured image has been loaded.
document.querySelector( '.wp-embed-featured-image img' ).addEventListener( 'load', function() { if ( featured_image ) {
sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) ); featured_image.addEventListener( 'load', function() {
} ); sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
} );
}
/** /**
* Detect clicks to external (_top) links. * Detect clicks to external (_top) links.