PDF Images: Avoid a PHP Warning when attempting to process a file without an extension.

Props chandrapatel for initial patch.
Merges [39580] to the 4.7 branch.
Fixes #39195.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39607 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2016-12-16 05:38:41 +00:00
parent 746b590ee7
commit c41a10ecb1
4 changed files with 24 additions and 2 deletions

View File

@ -146,10 +146,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
try {
$this->image = new Imagick();
$file_parts = pathinfo( $this->file );
$file_extension = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) );
$filename = $this->file;
if ( 'pdf' == strtolower( $file_parts['extension'] ) ) {
if ( 'pdf' == $file_extension ) {
$filename = $this->pdf_setup();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

View File

@ -542,4 +542,15 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase {
unlink( $save_to_file );
}
/**
* Test WP_Image_Editor_GD handles extension-less images
* @ticket 39195
*/
public function test_image_non_existent_extension() {
$image_editor = new WP_Image_Editor_GD( DIR_TESTDATA.'/images/test-image-no-extension' );
$result = $image_editor->load();
$this->assertTrue( $result );
}
}

View File

@ -531,4 +531,15 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$this->assertImageAlphaAtPointImagick( $save_to_file, array( 0, 0 ), $pre_rotate_alpha );
unlink( $save_to_file );
}
/**
* Test WP_Image_Editor_Imagick handles extension-less images
* @ticket 39195
*/
public function test_image_non_existent_extension() {
$image_editor = new WP_Image_Editor_Imagick( DIR_TESTDATA.'/images/test-image-no-extension' );
$result = $image_editor->load();
$this->assertTrue( $result );
}
}