WordPress.org

Make WordPress Core

Changeset 21772


Ignore:
Timestamp:
09/06/2012 09:50:41 AM (9 years ago)
Author:
koopersmith
Message:

Add checks for attachment metadata when formatting attachments for JS.

Prevents notices from causing malformed ajax responses.

see #21390.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r21769 r21772  
    15721572    );
    15731573
    1574     if ( 'image' === $type ) {
     1574    if ( $meta && 'image' === $type ) {
    15751575        $sizes = array();
    15761576        $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
    15771577
    1578         foreach ( $meta['sizes'] as $slug => $size ) {
    1579             $sizes[ $slug ] = array(
    1580                 'height'      => $size['height'],
    1581                 'width'       => $size['width'],
    1582                 'url'         => $base_url . $size['file'],
    1583                 'orientation' => $size['height'] > $size['width'] ? 'portrait' : 'landscape',
    1584             );
     1578        if ( isset( $meta['sizes'] ) ) {
     1579            foreach ( $meta['sizes'] as $slug => $size ) {
     1580                $sizes[ $slug ] = array(
     1581                    'height'      => $size['height'],
     1582                    'width'       => $size['width'],
     1583                    'url'         => $base_url . $size['file'],
     1584                    'orientation' => $size['height'] > $size['width'] ? 'portrait' : 'landscape',
     1585                );
     1586            }
    15851587        }
    15861588
Note: See TracChangeset for help on using the changeset viewer.