WordPress.org

Make WordPress Core

Changeset 28008


Ignore:
Timestamp:
04/07/2014 09:24:02 PM (8 years ago)
Author:
nacin
Message:

Gallery Views: Avoid JS errors when image attachments lack metadata.

props gcorne.
fixes #27691.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/mce-view.js

    r27987 r28008  
    290290
    291291                    _.each( attachments, function( attachment ) {
    292                         if ( attachment.sizes.thumbnail ) {
    293                             attachment.thumbnail = attachment.sizes.thumbnail;
    294                         } else {
    295                             attachment.thumbnail = attachment.sizes.full;
     292                        if ( attachment.sizes ) {
     293                            if ( attachment.sizes.thumbnail ) {
     294                                attachment.thumbnail = attachment.sizes.thumbnail;
     295                            } else if ( attachment.sizes.full ) {
     296                                attachment.thumbnail = attachment.sizes.full;
     297                            }
    296298                        }
    297299                    } );
  • trunk/src/wp-includes/media-template.php

    r28003 r28008  
    976976                    <dl class="gallery-item">
    977977                        <dt class="gallery-icon">
    978                             <img src="{{{ attachment.thumbnail.url }}}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
     978                            <# if ( attachment.thumbnail ) { #>
     979                                <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" />
     980                            <# } else { #>
     981                                <img src="{{ attachment.url }}" />
     982                            <# } #>
    979983                        </dt>
    980984                        <dd class="wp-caption-text gallery-caption">
Note: See TracChangeset for help on using the changeset viewer.