WordPress.org

Make WordPress Core

Ticket #23733: 23733.3.diff

File 23733.3.diff, 8.9 KB (added by wonderboymusic, 13 months ago)
  • wp-admin/custom-header.php

    diff --git wp-admin/custom-header.php wp-admin/custom-header.php
    index 7629af3..1228843 100644
    wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> 
    663663                        list( $width, $height, $type, $attr ) = getimagesize( $file ); 
    664664                } else { 
    665665                        $data = wp_get_attachment_metadata( $attachment_id ); 
    666                         $height = $data[ 'height' ]; 
    667                         $width = $data[ 'width' ]; 
     666                        $height = isset( $data[ 'height' ] ) ? $data[ 'height' ] : 0; 
     667                        $width = isset( $data[ 'width' ] ) ? $data[ 'width' ] : 0; 
    668668                        unset( $data ); 
    669669                } 
    670670 
  • wp-admin/includes/image-edit.php

    diff --git wp-admin/includes/image-edit.php wp-admin/includes/image-edit.php
    index b24d4f4..22e2095 100644
    function wp_image_editor($post_id, $msg = false) { 
    1313        $sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']); 
    1414        $note = ''; 
    1515 
    16         if ( is_array($meta) && isset($meta['width']) ) 
     16        if ( isset( $meta['width'], $meta['height'] ) ) 
    1717                $big = max( $meta['width'], $meta['height'] ); 
    1818        else 
    1919                die( __('Image data does not exist. Please re-upload the image.') ); 
    function wp_image_editor($post_id, $msg = false) { 
    2121        $sizer = $big > 400 ? 400 / $big : 1; 
    2222 
    2323        $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); 
    24         $can_restore = !empty($backup_sizes) && isset($backup_sizes['full-orig']) 
    25                 && $backup_sizes['full-orig']['file'] != basename($meta['file']); 
     24        $can_restore = false; 
     25        if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) 
     26                $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); 
    2627 
    2728        if ( $msg ) { 
    2829                if ( isset($msg->error) ) 
    function wp_image_editor($post_id, $msg = false) { 
    6364        <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" /> 
    6465        <input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" /> 
    6566        <input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" /> 
    66         <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo $meta['width']; ?>" /> 
    67         <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo $meta['height']; ?>" /> 
     67        <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> 
     68        <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> 
    6869 
    6970        <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap"> 
    7071        <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" /> 
    function wp_image_editor($post_id, $msg = false) { 
    8283                <a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Scale Image'); ?></strong></a> 
    8384                <div class="imgedit-help"> 
    8485                <p><?php _e('You can proportionally scale the original image. For best results the scaling should be done before performing any other operations on it like crop, rotate, etc. Note that if you make the image larger it may become fuzzy.'); ?></p> 
     86                <?php if ( isset( $meta['width'], $meta['height'] ) ): ?> 
    8587                <p><?php printf( __('Original dimensions %s'), $meta['width'] . '&times;' . $meta['height'] ); ?></p> 
     88                <?php endif ?> 
    8689                <div class="imgedit-submit"> 
    87                 <span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo $meta['width']; ?>" />&times;<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo $meta['height']; ?>" /> 
     90                <span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />&times;<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> 
    8891                <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span></span> 
    8992                <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" /> 
    9093                </div> 
    function wp_restore_image($post_id) { 
    499502                                        $delpath = apply_filters('wp_delete_file', $file); 
    500503                                        @unlink($delpath); 
    501504                                } 
    502                         } else { 
     505                        } elseif ( isset( $meta['width'], $meta['height'] ) ) { 
    503506                                $backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']); 
    504507                        } 
    505508                } 
  • wp-admin/includes/media.php

    diff --git wp-admin/includes/media.php wp-admin/includes/media.php
    index 1d6d91a..573c4db 100644
    function get_media_item( $attachment_id, $args = null ) { 
    11271127 
    11281128        $media_dims = ''; 
    11291129        $meta = wp_get_attachment_metadata( $post->ID ); 
    1130         if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) 
     1130        if ( isset( $meta['width'], $meta['height'] ) ) 
    11311131                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> "; 
    11321132        $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 
    11331133 
    function attachment_submitbox_metadata() { 
    23682368 
    23692369        $media_dims = ''; 
    23702370        $meta = wp_get_attachment_metadata( $post->ID ); 
    2371         if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) 
     2371        if ( isset( $meta['width'], $meta['height'] ) ) 
    23722372                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> "; 
    23732373        $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 
    23742374 
  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index f41f63e..4bfae0f 100644
    function image_downsize($id, $size = 'medium') { 
    164164                        $is_intermediate = true; 
    165165                } 
    166166        } 
    167         if ( !$width && !$height && isset($meta['width'], $meta['height']) ) { 
     167        if ( !$width && !$height && isset( $meta['width'], $meta['height'] ) ) { 
    168168                // any other type: use the real image 
    169169                $width = $meta['width']; 
    170170                $height = $meta['height']; 
    function gallery_shortcode($attr) { 
    780780        foreach ( $attachments as $id => $attachment ) { 
    781781                $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); 
    782782                $image_meta  = wp_get_attachment_metadata( $id ); 
    783                 $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; 
     783 
     784                $orientation = ''; 
     785                if ( isset( $image_meta['height'], $image_meta['width'] ) ) 
     786                        $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; 
    784787 
    785788                $output .= "<{$itemtag} class='gallery-item'>"; 
    786789                $output .= " 
    function wp_prepare_attachment_for_js( $attachment ) { 
    16261629                        } 
    16271630                } 
    16281631 
    1629                 $sizes['full'] = array( 
    1630                         'height'      => $meta['height'], 
    1631                         'width'       => $meta['width'], 
    1632                         'url'         => $attachment_url, 
    1633                         'orientation' => $meta['height'] > $meta['width'] ? 'portrait' : 'landscape', 
    1634                 ); 
     1632                $sizes['full'] = array( 'url' => $attachment_url ); 
     1633 
     1634                if ( isset( $meta['height'], $meta['width'] ) ) { 
     1635                        $sizes['full']['height'] = $meta['height']; 
     1636                        $sizes['full']['width'] = $meta['width']; 
     1637                        $sizes['full']['orientation'] = $meta['height'] > $meta['width'] ? 'portrait' : 'landscape'; 
     1638                } 
    16351639 
    16361640                $response = array_merge( $response, array( 'sizes' => $sizes ), $sizes['full'] ); 
    16371641        } 
  • wp-includes/theme.php

    diff --git wp-includes/theme.php wp-includes/theme.php
    index 8b8f42c..2150b46 100644
    function get_uploaded_header_images() { 
    10131013                $header_images[$header_index]['attachment_id'] =  $header->ID; 
    10141014                $header_images[$header_index]['url'] =  $url; 
    10151015                $header_images[$header_index]['thumbnail_url'] =  $url; 
    1016                 $header_images[$header_index]['width'] = $header_data['width']; 
    1017                 $header_images[$header_index]['height'] = $header_data['height']; 
     1016                if ( isset( $header_data['width'] ) ) 
     1017                        $header_images[$header_index]['width'] = $header_data['width']; 
     1018                if ( isset( $header_data['height'] ) ) 
     1019                        $header_images[$header_index]['height'] = $header_data['height']; 
    10181020        } 
    10191021 
    10201022        return $header_images;