WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/11/2014 03:41:31 AM (8 years ago)
Author:
wonderboymusic
Message:

Avoid a notice in wp_save_image() by checking $meta['sizes']['thumbnail'] for ! empty() before setting a variable to it.

Props MikeHansenMe.
Fixes #17736.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image-edit.php

    r28072 r28366  
    145145
    146146    </div>
    147    
     147
    148148    <div class="imgedit-panel-content">
    149149        <?php echo $note; ?>
    150150        <div class="imgedit-menu">
    151151            <div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php
    152    
     152
    153153        // On some setups GD library does not provide imagerotate() - Ticket #11536
    154154        if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { ?>
     
    161161            <div class="imgedit-rright disabled" title="<?php echo $note_no_rotate; ?>"></div>
    162162    <?php } ?>
    163    
     163
    164164            <div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div>
    165165            <div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph" title="<?php esc_attr_e( 'Flip horizontally' ); ?>"></div>
    166    
     166
    167167            <div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo disabled" title="<?php esc_attr_e( 'Undo' ); ?>"></div>
    168168            <div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo disabled" title="<?php esc_attr_e( 'Redo' ); ?>"></div>
    169169            <br class="clear" />
    170170        </div>
    171    
     171
    172172        <input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" />
    173173        <input type="hidden" id="imgedit-minthumb-<?php echo $post_id; ?>" value="<?php echo ( get_option('thumbnail_size_w') . ':' . get_option('thumbnail_size_h') ); ?>" />
     
    177177        <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
    178178        <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
    179    
     179
    180180        <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
    181181        <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); ?>" />
    182182        </div>
    183    
     183
    184184        <div class="imgedit-submit">
    185185            <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button" value="<?php esc_attr_e( 'Cancel' ); ?>" />
     
    187187        </div>
    188188    </div>
    189    
     189
    190190    </div>
    191191    <div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
     
    805805            } else {
    806806                $file_url = wp_get_attachment_url($post_id);
    807                 if ( $thumb = $meta['sizes']['thumbnail'] )
     807                if ( ! empty( $meta['sizes']['thumbnail'] ) && $thumb = $meta['sizes']['thumbnail'] ) {
    808808                    $return->thumbnail = path_join( dirname($file_url), $thumb['file'] );
    809                 else
     809                } else {
    810810                    $return->thumbnail = "$file_url?w=128&h=128";
     811                }
    811812            }
    812813        }
Note: See TracChangeset for help on using the changeset viewer.