Make WordPress Core

Ticket #43139: 43139.2.diff

File 43139.2.diff, 1.6 KB (added by westonruter, 7 years ago)
  • src/wp-includes/widgets/class-wp-widget-media-gallery.php

    diff --git src/wp-includes/widgets/class-wp-widget-media-gallery.php src/wp-includes/widgets/class-wp-widget-media-gallery.php
    index 13ee9c2d6e..ec00022104 100644
    class WP_Widget_Media_Gallery extends WP_Widget_Media { 
    169169                ?>
    170170                <script type="text/html" id="tmpl-wp-media-widget-gallery-preview">
    171171                        <# var describedById = 'describedBy-' + String( Math.random() ); #>
    172                         <# if ( data.ids.length ) { #>
     172                        <#
     173                        var ids = _.filter( data.ids, function( id ) {
     174                                return ( id in data.attachments );
     175                        } );
     176                        #>
     177                        <# if ( ids.length ) { #>
    173178                                <div class="gallery media-widget-gallery-preview">
    174                                         <# _.each( data.ids, function( id, index ) { #>
    175                                                 <#
    176                                                 var attachment = data.attachments[ id ];
    177                                                 if ( ! attachment ) {
    178                                                         return;
    179                                                 }
    180                                                 #>
     179                                        <# _.each( ids, function( id, index ) { #>
     180                                                <# var attachment = data.attachments[ id ]; #>
    181181                                                <# if ( index < 6 ) { #>
    182182                                                        <dl class="gallery-item">
    183183                                                                <dt class="gallery-icon">
    class WP_Widget_Media_Gallery extends WP_Widget_Media { 
    186186                                                                <# } else { #>
    187187                                                                        <img src="{{ attachment.url }}" alt="" />
    188188                                                                <# } #>
    189                                                                 <# if ( index === 5 && data.ids.length > 6 ) { #>
     189                                                                <# if ( index === 5 && ids.length > 6 ) { #>
    190190                                                                        <div class="gallery-icon-placeholder">
    191                                                                                 <p class="gallery-icon-placeholder-text">+{{ data.ids.length - 5 }}</p>
     191                                                                                <p class="gallery-icon-placeholder-text">+{{ ids.length - 5 }}</p>
    192192                                                                        </div>
    193193                                                                <# } #>
    194194                                                                </dt>