Embeds: Improve height calculation for slow loading images.

When the featured image takes longer to load, the browser might not know its exact dimensions yet and therefore sends an incorrect document height to the embedding site.

By sending the document's height again after the featured image has been loaded, we ensure that the iframe doesn't get cut off.

Fixes #35657.

git-svn-id: https://develop.svn.wordpress.org/trunk@37745 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2016-06-18 09:59:54 +00:00
parent ddd6c2d94d
commit c3394e2c93
1 changed files with 5 additions and 0 deletions

View File

@ -138,6 +138,11 @@
*/
sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
// Send the document's height again after the featured image has been loaded.
document.querySelector( '.wp-embed-featured-image img' ).addEventListener( 'load', function() {
sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
} );
/**
* Detect clicks to external (_top) links.
*/