From f68b6006decaaf839bab7e12ff2fc2202625bb40 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 14 Nov 2012 14:26:52 +0000 Subject: [PATCH] wp_generate_attachment_metadata() should not call WP_Image_Editor if there's nothing to resize. props mdawaffe. fixes #22438. git-svn-id: http://core.svn.wordpress.org/trunk@22571 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 6eca7ba858..053639baa5 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -99,10 +99,14 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) { $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes ); - $editor = WP_Image_Editor::get_instance( $file ); + if ( $sizes ) { + $editor = WP_Image_Editor::get_instance( $file ); - if ( ! is_wp_error( $editor ) ) - $metadata['sizes'] = $editor->multi_resize( $sizes ); + if ( ! is_wp_error( $editor ) ) + $metadata['sizes'] = $editor->multi_resize( $sizes ); + } else { + $metadata['sizes'] = array(); + } // fetch additional metadata from exif/iptc $image_meta = wp_read_image_metadata( $file );