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-admin/includes/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
$support = false;
$mime_type = get_post_mime_type( $attachment );

if ( 'image/heic' === $mime_type || ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image( $file ) ) ) {
if ( wp_is_heic_image_mime_type( $mime_type ) || ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image( $file ) ) ) {
// Make thumbnails and other intermediate sizes.
$metadata = wp_create_image_subsizes( $file, $attachment_id );
} elseif ( wp_attachment_is( 'video', $attachment ) ) {
Expand Down
16 changes: 5 additions & 11 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3120,6 +3120,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
$real_mime = wp_get_image_mime( $file );

$heic_images_extensions = array(
'heic',
'heif',
'heics',
'heifs',
Expand All @@ -3144,16 +3145,10 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
'image/webp' => 'webp',
'image/avif' => 'avif',

/*
* In theory there are/should be file extensions that correspond to the
* mime types: .heif, .heics and .heifs. However it seems that HEIC images
* with any of the mime types commonly have a .heic file extension.
* Seems keeping the status quo here is best for compatibility.
*/
'image/heic' => 'heic',
'image/heif' => 'heic',
'image/heic-sequence' => 'heic',
'image/heif-sequence' => 'heic',
'image/heif' => 'heif',
'image/heic-sequence' => 'heics',
'image/heif-sequence' => 'heifs',
)
);

Expand Down Expand Up @@ -3470,7 +3465,6 @@ function wp_get_mime_types() {
'avif' => 'image/avif',
'ico' => 'image/x-icon',

// TODO: Needs improvement. All images with the following mime types seem to have .heic file extension.
'heic' => 'image/heic',
'heif' => 'image/heif',
'heics' => 'image/heic-sequence',
Expand Down Expand Up @@ -3595,7 +3589,7 @@ function wp_get_ext_types() {
return apply_filters(
'ext2type',
array(
'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic', 'heif', 'webp', 'avif' ),
'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic', 'heif', 'heics', 'heifs', 'webp', 'avif' ),
'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'flac', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ),
'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf' ),
Expand Down
Loading