Commit eca9b9a0 authored by Joe Hoyle's avatar Joe Hoyle
Browse files

Fix saving image with imagick

parent 90e7f2f2
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -21,8 +21,12 @@ class S3_Uploads_Image_Editor_Imagick extends WP_Image_Editor_Imagick {

		$save = parent::_save( $image, $temp_filename, $mime_type );

		if ( ! is_wp_error( $save ) ) {
			copy( $temp_filename, $filename );
		if ( is_wp_error( $save ) ) {
			return $save;
		}

		if ( ! copy( $save['path'], $filename ) ) {
			return new WP_Error( 'unable-to-copy-to-s3', 'Unable to copy the temp image to S3' );
		}

		return array(
+12 −0
Original line number Diff line number Diff line
@@ -55,5 +55,17 @@ class Test_S3_Uploads_Image_Editor_Imagick extends WP_UnitTestCase {
		$this->assertEquals( 'canola-100x100.jpg', $status['file'] );
		$this->assertEquals( 100, $status['width'] );
		$this->assertEquals( 100, $status['height'] );

		$image = getimagesize( $status['path'] );

		$this->assertEquals( array(
			100,
			100,
			2,
			'width="100" height="100"',
			'bits' => 8,
			'channels' => 3,
			'mime' => 'image/jpeg'
		), $image );
	}
}
 No newline at end of file