Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -5879,7 +5879,7 @@ function _wp_add_additional_image_sizes() {
function wp_show_heic_upload_error( $plupload_settings ) {
// Check if HEIC images can be edited.
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/heic' ) ) ) {
$plupload_init['heic_upload_error'] = true;
$plupload_settings['heic_upload_error'] = true;
}
return $plupload_settings;
}
Expand Down
37 changes: 37 additions & 0 deletions tests/phpunit/tests/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -7843,6 +7843,43 @@ public function test_wp_get_image_encode_quality_clamps_out_of_range() {
$this->assertSame( 1, wp_get_image_encode_quality( 'image/png' ) );
remove_filter( 'wp_editor_set_quality', $zero );
}

/**
* Ensures the HEIC upload error flag is added when image editors do not support HEIC.
*
* @ticket 65802
*/
public function test_wp_show_heic_upload_error_adds_flag_when_not_supported() {
// Force the editor check to return false.
add_filter( 'wp_image_editors', '__return_empty_array' );

$settings = array( 'existing' => 'value' );
$result = wp_show_heic_upload_error( $settings );

$this->assertArrayHasKey( 'heic_upload_error', $result, 'The heic_upload_error key is expected to be added to the array.' );
$this->assertTrue( $result['heic_upload_error'], 'The heic_upload_error flag is expected to be true.' );
$this->assertArrayHasKey( 'existing', $result, 'Existing array keys are expected to be preserved.' );
$this->assertSame( 'value', $result['existing'], 'Existing array values are expected to remain unmodified.' );
}

/**
* Ensures the HEIC upload error flag is absent when image editors support HEIC.
*
* @ticket 65802
*/
public function test_wp_show_heic_upload_error_omits_flag_when_supported() {
// Skip if the environment cannot support HEIC.
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/heic' ) ) ) {
$this->markTestSkipped( 'HEIC is not supported by the selected image editor.' );
}

$settings = array( 'existing' => 'value' );
$result = wp_show_heic_upload_error( $settings );

$this->assertArrayNotHasKey( 'heic_upload_error', $result, 'The heic_upload_error key is not expected to be present when HEIC is supported.' );
$this->assertArrayHasKey( 'existing', $result, 'Existing array keys are expected to be preserved.' );
$this->assertSame( 'value', $result['existing'], 'Existing array values are expected to remain unmodified.' );
}
}

/**
Expand Down
Loading