PDF Images: Avoid a PHP Warning when attempting to process a file without an extension.
Props chandrapatel for initial patch. Fixes #39195. git-svn-id: https://develop.svn.wordpress.org/trunk@39580 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
caa1f1f88d
commit
24228daabf
@ -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();
|
||||
}
|
||||
|
||||
|
BIN
tests/phpunit/data/images/test-image-no-extension
Normal file
BIN
tests/phpunit/data/images/test-image-no-extension
Normal file
Binary file not shown.
After Width: | Height: | Size: 524 B |
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user