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.


Built from https://develop.svn.wordpress.org/trunk@44661


git-svn-id: http://core.svn.wordpress.org/trunk@44492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2019-01-21 04:13:51 +00:00
parent c0debca1f3
commit 989a28b482
2 changed files with 11 additions and 11 deletions

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.1-beta1-44660';
$wp_version = '5.1-beta1-44661';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -176,15 +176,15 @@ class WP_Widget_Media_Gallery extends WP_Widget_Media {
?>
<script type="text/html" id="tmpl-wp-media-widget-gallery-preview">
<# var describedById = 'describedBy-' + String( Math.random() ); #>
<# if ( data.ids.length ) { #>
<#
var ids = _.filter( data.ids, function( id ) {
return ( id in data.attachments );
} );
#>
<# if ( ids.length ) { #>
<div class="gallery media-widget-gallery-preview">
<# _.each( data.ids, function( id, index ) { #>
<#
var attachment = data.attachments[ id ];
if ( ! attachment ) {
return;
}
#>
<# _.each( ids, function( id, index ) { #>
<# var attachment = data.attachments[ id ]; #>
<# if ( index < 6 ) { #>
<dl class="gallery-item">
<dt class="gallery-icon">
@ -193,9 +193,9 @@ class WP_Widget_Media_Gallery extends WP_Widget_Media {
<# } else { #>
<img src="{{ attachment.url }}" alt="" />
<# } #>
<# if ( index === 5 && data.ids.length > 6 ) { #>
<# if ( index === 5 && ids.length > 6 ) { #>
<div class="gallery-icon-placeholder">
<p class="gallery-icon-placeholder-text">+{{ data.ids.length - 5 }}</p>
<p class="gallery-icon-placeholder-text">+{{ ids.length - 5 }}</p>
</div>
<# } #>
</dt>