Make WordPress Core

Changeset 44661


Ignore:
Timestamp:
01/21/2019 04:12:10 AM (8 years ago)
Author:
pento
Message:

Widgets: Fix Gallery Widget preview after an image is deleted.

The Gallery Widget incorrectly tried to include the deleted image in the preview.

Props westonruter, janak007, afercia, mrasharirfan.
Fixes #43139.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-media-gallery.php

    r43571 r44661  
    177177                <script type="text/html" id="tmpl-wp-media-widget-gallery-preview">
    178178                        <# var describedById = 'describedBy-' + String( Math.random() ); #>
    179                         <# if ( data.ids.length ) { #>
     179                        <#
     180                        var ids = _.filter( data.ids, function( id ) {
     181                                return ( id in data.attachments );
     182                        } );
     183                        #>
     184                        <# if ( ids.length ) { #>
    180185                                <div class="gallery media-widget-gallery-preview">
    181                                         <# _.each( data.ids, function( id, index ) { #>
    182                                                 <#
    183                                                 var attachment = data.attachments[ id ];
    184                                                 if ( ! attachment ) {
    185                                                         return;
    186                                                 }
    187                                                 #>
     186                                        <# _.each( ids, function( id, index ) { #>
     187                                                <# var attachment = data.attachments[ id ]; #>
    188188                                                <# if ( index < 6 ) { #>
    189189                                                        <dl class="gallery-item">
     
    194194                                                                        <img src="{{ attachment.url }}" alt="" />
    195195                                                                <# } #>
    196                                                                 <# if ( index === 5 && data.ids.length > 6 ) { #>
     196                                                                <# if ( index === 5 && ids.length > 6 ) { #>
    197197                                                                        <div class="gallery-icon-placeholder">
    198                                                                                 <p class="gallery-icon-placeholder-text">+{{ data.ids.length - 5 }}</p>
     198                                                                                <p class="gallery-icon-placeholder-text">+{{ ids.length - 5 }}</p>
    199199                                                                        </div>
    200200                                                                <# } #>
Note: See TracChangeset for help on using the changeset viewer.