Check for WP_Error return from WP_Image_Editor::get_instance().
Props markoheijnen see #6821 git-svn-id: http://core.svn.wordpress.org/trunk@22192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
91ef55e891
commit
da8d7a347a
|
@ -568,7 +568,7 @@ function wp_save_image( $post_id ) {
|
||||||
$post = get_post( $post_id );
|
$post = get_post( $post_id );
|
||||||
|
|
||||||
$img = WP_Image_Editor::get_instance( _load_image_to_edit_path( $post_id, 'full' ) );
|
$img = WP_Image_Editor::get_instance( _load_image_to_edit_path( $post_id, 'full' ) );
|
||||||
if ( !$img ) {
|
if ( is_wp_error( $img ) ) {
|
||||||
$return->error = esc_js( __('Unable to create new image.') );
|
$return->error = esc_js( __('Unable to create new image.') );
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,10 @@ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = WP_Image_Editor::get_instance( $src_file );
|
$editor = WP_Image_Editor::get_instance( $src_file );
|
||||||
$src = $editor->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs );
|
if ( is_wp_error( $editor ) )
|
||||||
|
return $editor;
|
||||||
|
|
||||||
|
$src = $editor->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs );
|
||||||
if ( is_wp_error( $src ) )
|
if ( is_wp_error( $src ) )
|
||||||
return $src;
|
return $src;
|
||||||
|
|
||||||
|
@ -94,7 +96,9 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||||
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
|
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
|
||||||
|
|
||||||
$editor = WP_Image_Editor::get_instance( $file );
|
$editor = WP_Image_Editor::get_instance( $file );
|
||||||
$metadata['sizes'] = $editor->multi_resize( $sizes );
|
|
||||||
|
if ( ! is_wp_error( $editor ) )
|
||||||
|
$metadata['sizes'] = $editor->multi_resize( $sizes );
|
||||||
|
|
||||||
// fetch additional metadata from exif/iptc
|
// fetch additional metadata from exif/iptc
|
||||||
$image_meta = wp_read_image_metadata( $file );
|
$image_meta = wp_read_image_metadata( $file );
|
||||||
|
|
|
@ -383,7 +383,7 @@ function image_make_intermediate_size( $file, $width, $height, $crop = false ) {
|
||||||
if ( $width || $height ) {
|
if ( $width || $height ) {
|
||||||
$editor = WP_Image_Editor::get_instance( $file );
|
$editor = WP_Image_Editor::get_instance( $file );
|
||||||
|
|
||||||
if ( is_wp_error( $editor->resize( $width, $height, $crop ) ) );
|
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) );
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$resized_file = $editor->save();
|
$resized_file = $editor->save();
|
||||||
|
|
Loading…
Reference in New Issue