Make WordPress Core

Ticket #36521: 35612.1.diff

File 35612.1.diff, 1.1 KB (added by TimothyBlynJacobs, 7 years ago)
  • src/wp-admin/js/customize-controls.js

     
    17961796
    17971797                        control.setting.bind( function( value ) {
    17981798
     1799                                 var attachmentNeedsUpdating = control.params.attachment.id != value;
     1800
    17991801                                // Send attachment information to the preview for possible use in `postMessage` transport.
    18001802                                wp.media.attachment( value ).fetch().done( function() {
    18011803                                        wp.customize.previewer.send( control.setting.id + '-attachment-data', this.attributes );
     1804
     1805                                        if ( attachmentNeedsUpdating ) {
     1806                                                control.params.attachment = this.attributes;
     1807                                                control.renderContent();
     1808                                        }
    18021809                                } );
    18031810
    1804                                 // Re-render whenever the control's setting changes.
    1805                                 control.renderContent();
     1811                                if ( ! value ) {
     1812                                        control.params.attachment = {};
     1813                                }
     1814
     1815                                if ( ! attachmentNeedsUpdating || ! value ) {
     1816                                        // Re-render whenever the control's setting changes.
     1817                                        control.renderContent();
     1818                                }
    18061819                        } );
    18071820                },
    18081821