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. git-svn-id: https://develop.svn.wordpress.org/trunk@44661 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3ea21b66d8
commit
02422aab1d
@ -176,15 +176,15 @@ class WP_Widget_Media_Gallery extends WP_Widget_Media {
|
|||||||
?>
|
?>
|
||||||
<script type="text/html" id="tmpl-wp-media-widget-gallery-preview">
|
<script type="text/html" id="tmpl-wp-media-widget-gallery-preview">
|
||||||
<# var describedById = 'describedBy-' + String( Math.random() ); #>
|
<# 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">
|
<div class="gallery media-widget-gallery-preview">
|
||||||
<# _.each( data.ids, function( id, index ) { #>
|
<# _.each( ids, function( id, index ) { #>
|
||||||
<#
|
<# var attachment = data.attachments[ id ]; #>
|
||||||
var attachment = data.attachments[ id ];
|
|
||||||
if ( ! attachment ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#>
|
|
||||||
<# if ( index < 6 ) { #>
|
<# if ( index < 6 ) { #>
|
||||||
<dl class="gallery-item">
|
<dl class="gallery-item">
|
||||||
<dt class="gallery-icon">
|
<dt class="gallery-icon">
|
||||||
@ -193,9 +193,9 @@ class WP_Widget_Media_Gallery extends WP_Widget_Media {
|
|||||||
<# } else { #>
|
<# } else { #>
|
||||||
<img src="{{ attachment.url }}" alt="" />
|
<img src="{{ attachment.url }}" alt="" />
|
||||||
<# } #>
|
<# } #>
|
||||||
<# if ( index === 5 && data.ids.length > 6 ) { #>
|
<# if ( index === 5 && ids.length > 6 ) { #>
|
||||||
<div class="gallery-icon-placeholder">
|
<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>
|
</div>
|
||||||
<# } #>
|
<# } #>
|
||||||
</dt>
|
</dt>
|
||||||
|
Loading…
Reference in New Issue
Block a user