Opened 7 months ago

Closed 7 months ago

#22181 closed defect (bug) (fixed)

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

Reported by: gandham Owned by: markoheijnen
Priority: normal Milestone: 3.5
Component: Media Version: 3.5
Severity: major Keywords: has-patch commit needs-unit-tests
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 7 months ago.
Simple patch.

Download all attachments as: .zip

Change History (7)

Simple patch.

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

In [22225]:

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

  • Keywords needs-unit-tests added

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

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

I will now look in to that.

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

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