WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#22181 closed defect (bug) (fixed)

image_make_intermediate_size in wp-includes/media.php always returns FALSE

Reported by: gandham Owned by: markoheijnen
Milestone: 3.5 Priority: normal
Severity: major Version: 3.5
Component: Media Keywords: has-patch commit needs-unit-tests
Focuses: Cc:

Description

Found this when one of my theme user running 3.5 reported problem with thumbnails. http://swiftthemes.com/forums/showthread.php?1958-here-we-go-again-thumbnail-featured-pics-dont-work-in-latest-build-of-wordpress&goto=newpost#post7055

In the following function, if statement is followed by a ;, so this always returns false.

function image_make_intermediate_size( $file, $width, $height, $crop = false ) {
	if ( $width || $height ) {
		$editor = WP_Image_Editor::get_instance( $file );

		if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) );
			return false;

		$resized_file = $editor->save();

		if ( ! is_wp_error( $resized_file ) && $resized_file ) {
			unset( $resized_file['path'] );
			return $resized_file;
		}
	}
	return false;
}

Attachments (1)

media.patch (541 bytes) - added by gandham 6 years ago.
Simple patch.

Download all attachments as: .zip

Change History (7)

@gandham
6 years ago

Simple patch.

#1 @SergeyBiryukov
6 years ago

  • Component changed from General to Media
  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.5

#2 @nacin
6 years ago

In [22225]:

Fix typo and don't always return false from image_make_intermediate_size(). props gandham, see #22181.

#3 @nacin
6 years ago

  • Keywords needs-unit-tests added

I don't like that no unit tests failed for this.

#4 @markoheijnen
6 years ago

  • Owner set to markoheijnen
  • Status changed from new to assigned

I will now look in to that.

#5 @markoheijnen
6 years ago

Created a ticket at the unit test trac for this. It does include a file with four tests. See #UT135

#6 @SergeyBiryukov
6 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.