Commit 6b0edddb54 for wordpress.org
commit 6b0edddb54102e991d9d5af1e6759fdb7e310600
Author: Weston Ruter <weston@xwp.co>
Date: Mon Feb 2 06:14:44 2026 +0000
Customize: Use `wp_check_filetype()` instead of `substr()` to extract file extension.
This fixes compatibility with image files that have 4-character extensions, such as `.webp` and `.avif`.
Follow-up to [57524], [50810], [30309].
Props buutqn, westonruter.
See #51228, #35725, #21483.
Fixes #64557.
Built from https://develop.svn.wordpress.org/trunk@61576
git-svn-id: http://core.svn.wordpress.org/trunk@60887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/customize/class-wp-customize-media-control.php b/wp-includes/customize/class-wp-customize-media-control.php
index af137512c4..40d644ca84 100644
--- a/wp-includes/customize/class-wp-customize-media-control.php
+++ b/wp-includes/customize/class-wp-customize-media-control.php
@@ -92,8 +92,9 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
* Fake an attachment model - needs all fields used by template.
* Note that the default value must be a URL, NOT an attachment ID.
*/
- $ext = substr( $this->setting->default, -3 );
- $type = in_array( $ext, array( 'jpg', 'png', 'gif', 'bmp', 'webp', 'avif' ), true ) ? 'image' : 'document';
+ $ext = wp_check_filetype( $this->setting->default )['ext'];
+ $ext_types = wp_get_ext_types();
+ $type = isset( $ext_types['image'] ) && in_array( $ext, $ext_types['image'], true ) ? 'image' : 'document';
$default_attachment = array(
'id' => 1,
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 9b60d8c058..ac0201e095 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61575';
+$wp_version = '7.0-alpha-61576';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.