Gallery Views: Avoid JS errors when image attachments lack metadata.
props gcorne. fixes #27691. Built from https://develop.svn.wordpress.org/trunk@28008 git-svn-id: http://core.svn.wordpress.org/trunk@27838 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
684145ca81
commit
b00e343a25
|
@ -289,10 +289,12 @@ window.wp = window.wp || {};
|
|||
attachments = this.attachments.toJSON();
|
||||
|
||||
_.each( attachments, function( attachment ) {
|
||||
if ( attachment.sizes.thumbnail ) {
|
||||
attachment.thumbnail = attachment.sizes.thumbnail;
|
||||
} else {
|
||||
attachment.thumbnail = attachment.sizes.full;
|
||||
if ( attachment.sizes ) {
|
||||
if ( attachment.sizes.thumbnail ) {
|
||||
attachment.thumbnail = attachment.sizes.thumbnail;
|
||||
} else if ( attachment.sizes.full ) {
|
||||
attachment.thumbnail = attachment.sizes.full;
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -975,7 +975,11 @@ function wp_print_media_templates() {
|
|||
<# _.each( data.attachments, function( attachment, index ) { #>
|
||||
<dl class="gallery-item">
|
||||
<dt class="gallery-icon">
|
||||
<img src="{{{ attachment.thumbnail.url }}}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
|
||||
<# if ( attachment.thumbnail ) { #>
|
||||
<img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
|
||||
<# } else { #>
|
||||
<img src="{{ attachment.url }}" />
|
||||
<# } #>
|
||||
</dt>
|
||||
<dd class="wp-caption-text gallery-caption">
|
||||
{{ attachment.caption }}
|
||||
|
|
Loading…
Reference in New Issue