mirror of
git://develop.git.wordpress.org/
synced 2025-02-22 23:54:09 +01:00
Media: Recognize .ico
files as displayable images on PHP 5.3+ and allow attachment meta data to be generated for them.
Props remyvv, Guido07111975. Fixes #43458. git-svn-id: https://develop.svn.wordpress.org/trunk@42780 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9de76899c1
commit
007a7caad4
@ -556,6 +556,11 @@ function file_is_valid_image( $path ) {
|
||||
function file_is_displayable_image( $path ) {
|
||||
$displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP );
|
||||
|
||||
// IMAGETYPE_ICO is only defined in PHP 5.3+.
|
||||
if ( defined( 'IMAGETYPE_ICO' ) ) {
|
||||
$displayable_image_types[] = IMAGETYPE_ICO;
|
||||
}
|
||||
|
||||
$info = @getimagesize( $path );
|
||||
if ( empty( $info ) ) {
|
||||
$result = false;
|
||||
|
BIN
tests/phpunit/data/images/test-image.ico
Normal file
BIN
tests/phpunit/data/images/test-image.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
@ -61,6 +61,11 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
'test-image.jpg',
|
||||
);
|
||||
|
||||
// IMAGETYPE_ICO is only defined in PHP 5.3+.
|
||||
if ( defined( 'IMAGETYPE_ICO' ) ) {
|
||||
$files[] = 'test-image.ico';
|
||||
}
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
$this->assertTrue( file_is_valid_image( DIR_TESTDATA . '/images/' . $file ), "file_is_valid_image($file) should return true" );
|
||||
}
|
||||
@ -87,6 +92,11 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
'test-image.jpg',
|
||||
);
|
||||
|
||||
// IMAGETYPE_ICO is only defined in PHP 5.3+.
|
||||
if ( defined( 'IMAGETYPE_ICO' ) ) {
|
||||
$files[] = 'test-image.ico';
|
||||
}
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
$this->assertTrue( file_is_displayable_image( DIR_TESTDATA . '/images/' . $file ), "file_is_valid_image($file) should return true" );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user