Make WordPress Core

Changeset 37977


Ignore:
Timestamp:
07/05/2016 04:15:05 PM (9 years ago)
Author:
ocean90
Message:

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

Props swissspidy.
Fixes #35657.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/wp-embed-template.js

    r37745 r37977  
    2727            share_input = document.querySelectorAll( '.wp-embed-share-input' ),
    2828            share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ),
     29            featured_image = document.querySelector( '.wp-embed-featured-image img' ),
    2930            i;
    3031
     
    140141
    141142        // Send the document's height again after the featured image has been loaded.
    142         document.querySelector( '.wp-embed-featured-image img' ).addEventListener( 'load', function() {
    143             sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
    144         } );
     143        if ( featured_image ) {
     144            featured_image.addEventListener( 'load', function() {
     145                sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
     146            } );
     147        }
    145148
    146149        /**
Note: See TracChangeset for help on using the changeset viewer.