Commit 9109fd4b6a for wordpress.org
commit 9109fd4b6af51a0d39f1b3fe9dc8caf76102f0a2
Author: desrosj <desrosj@git.wordpress.org>
Date: Mon Dec 1 00:36:32 2025 +0000
Media: Adjustments for official HEIF/HEIC support in added in PHP 8.5.
Now that a version of `imagick` with support for PHP 8.5 has been released and the containers maintained by the project for the local development environemnt have been updated to include it, there are some new PHP 8.5 compatibility issues that have surfaced related to HEIF/HEIC image format.
PHP 8.5 added support for the HEIF/HEIC image format in `getimagesize()`. To properly support this in a cross-version way, a few changes are necessary.
Since [58849], WordPress has supported this format and the `IMAGETYPE_HEIC` constant was introduced as a placeholder until proper support was added in PHP. Since that has now happened, this constant needs to be changed to contain a value of `20` instead of `99`, and the name upstream was added as `IMAGETYPE_HEIF`. The constant in Core is being changed to match those included in PHP.
The implementation for this image format in `getimagesize()` also follows a similar pattern to that of AVIF where additional information such as the image `bits` and `channels` are also returned. This additional information is causing unit tests to fail. The tests have been updated to account for different versions of PHP returning a different level of detail.
Props westonruter, skithund, johnbillion, adamsilverstein.
Fixes #64322.
Built from https://develop.svn.wordpress.org/trunk@61328
git-svn-id: http://core.svn.wordpress.org/trunk@60640 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/compat.php b/wp-includes/compat.php
index 3007498892..af733c830d 100644
--- a/wp-includes/compat.php
+++ b/wp-includes/compat.php
@@ -614,7 +614,7 @@ if ( ! defined( 'IMG_AVIF' ) ) {
define( 'IMG_AVIF', IMAGETYPE_AVIF );
}
-// IMAGETYPE_HEIC constant is not yet defined in PHP as of PHP 8.3.
-if ( ! defined( 'IMAGETYPE_HEIC' ) ) {
- define( 'IMAGETYPE_HEIC', 99 );
+// IMAGETYPE_HEIF constant is only defined in PHP 8.5 or later.
+if ( ! defined( 'IMAGETYPE_HEIF' ) ) {
+ define( 'IMAGETYPE_HEIF', 20 );
}
diff --git a/wp-includes/media.php b/wp-includes/media.php
index be41add659..229d22b849 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -5829,7 +5829,7 @@ function wp_getimagesize( $filename, ?array &$image_info = null ) {
return array(
$size['width'],
$size['height'],
- IMAGETYPE_HEIC,
+ IMAGETYPE_HEIF,
sprintf(
'width="%d" height="%d"',
$size['width'],
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 74a7a0ef1a..6bdba23353 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61327';
+$wp_version = '7.0-alpha-61328';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.