feat: bypass real MIME type check for uploads
Added a function to disable the real MIME type check via the 'wp_check_filetype_and_ext' filter. This adjustment helps to allow files that pass the extension check but not the MIME type check, addressing issues with certain file uploads failing due to MIME type inconsistencies.
This commit is contained in:
parent
2b03226a50
commit
e2530b5da7
1 changed files with 11 additions and 1 deletions
|
@ -832,4 +832,14 @@ function allow_more_uploads($mime_types) {
|
|||
$mime_types['py'] = 'text/x-python';
|
||||
return $mime_types;
|
||||
}
|
||||
add_filter('upload_mimes', 'allow_more_uploads');
|
||||
add_filter('upload_mimes', 'allow_more_uploads');
|
||||
|
||||
function disable_real_mime_check($data, $file, $filename, $mimes) {
|
||||
$wp_filetype = wp_check_filetype($filename, $mimes);
|
||||
$ext = $wp_filetype['ext'];
|
||||
$type = $wp_filetype['type'];
|
||||
$proper_filename = $data['proper_filename'];
|
||||
|
||||
return compact('ext', 'type', 'proper_filename');
|
||||
}
|
||||
add_filter('wp_check_filetype_and_ext', 'disable_real_mime_check', 10, 4);
|
Loading…
Reference in a new issue