Skip to content

Commit bf9f644

Browse files
Media: Allow HEIC/HEIF uploads when server lacks support
Bypass the `wp_prevent_unsupported_mime_type_uploads` check for HEIC/HEIF images so they can be stored even when the server's image editor doesn't support them. The client-side canvas fallback handles processing using the browser's native HEVC decoder via createImageBitmap().
1 parent b00a9eb commit bf9f644

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,17 @@ public function create_item_permissions_check( $request ) {
258258
$prevent_unsupported_uploads = false;
259259
}
260260

261+
// Always allow HEIC/HEIF uploads through even if the server's image
262+
// editor doesn't support them. The client-side canvas fallback will
263+
// handle processing using the browser's native HEVC decoder.
264+
if (
265+
$prevent_unsupported_uploads &&
266+
! empty( $files['file']['type'] ) &&
267+
wp_is_heic_image_mime_type( $files['file']['type'] )
268+
) {
269+
$prevent_unsupported_uploads = false;
270+
}
271+
261272
// If the upload is an image, check if the server can handle the mime type.
262273
if (
263274
$prevent_unsupported_uploads &&

0 commit comments

Comments
 (0)