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
This commit is contained in:
Andrew Nacin 2012-11-14 14:26:52 +00:00
parent 39528d3c11
commit f68b6006de

View File

@ -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 );