Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #63294, comment 6


Ignore:
Timestamp:
04/17/2025 07:17:03 PM (19 months ago)
Author:
QuietNoise

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #63294, comment 6

    v1 v2  
    1212Also this works without issues in older versions i.e. 6.7.1 and 6.7.2. The problem was introduced in 6.8 seems.
    1313
     14**Edit:**
     15I nailed it down to new code introduced in function **create_item_permissions_check()** in version 6.8.
     16
     17Further down the code it appears that** wp_image_editor_supports()** returns false if image editing lirary is not enabled on server.
     18
     19I believe this is not a correct approach since whether file can be edited or not should not determine whether file can be uploaded or not. Not all servers have support for Imagick or GD and these should not be punished if admins are not planning to use image editing feature in a first place.
     20
     21**Workaround**
     22Together with the new code mentioned above a new filter was introduced in WP 6.8: **wp_prevent_unsupported_mime_type_uploads**
     23It can be used to disable this new behaviour.
     24
     25Nuclear option would be:
     26
     27{{{#!php
     28<?php
     29add_filter( 'wp_prevent_unsupported_mime_type_uploads', '__return_false' );
     30}}}
     31
     32More gradual option would be to expand the function to check what mime type is passed and return false only for images or whatever other file type affected in your project.
     33The filter function passes mime type string. So, it could be something like this:
     34
     35{{{#!php
     36<?php
     37add_filter( 'wp_prevent_unsupported_mime_type_uploads', function($current, $mime) {
     38        return str_starts_with( $mime, 'image/' ) ? false : $current;
     39}, 10, 2);
     40}}}