[wp-trac] [WordPress Trac] #63302: SVG images can't be uploaded anymore due to a resizing issue

WordPress Trac noreply at wordpress.org
Fri Apr 18 04:53:33 UTC 2025


#63302: SVG images can't be uploaded anymore due to a resizing issue
-----------------------------+---------------------
 Reporter:  audrasjb         |       Owner:  (none)
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  6.8.1
Component:  Editor           |     Version:  6.8
 Severity:  normal           |  Resolution:
 Keywords:  has-screenshots  |     Focuses:
-----------------------------+---------------------

Comment (by sainathpoojary):

 Hey @audrasjb,

 I've identified an issue with SVG uploads in WordPress 6.8 that was
 introduced in [https://core.trac.wordpress.org/changeset/60084 changeset
 60084].

 After investigating [https://core.trac.wordpress.org/changeset/60084
 changeset 60084], I found that two different implementations were added
 for handling unsupported image formats:|

 1. Media Library path (wp-admin/includes/media.php):

 {{{
 if ( $prevent_unsupported_uploads ) {
     // Check if WebP images can be edited.
     if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' )
 ) ) {
         $plupload_init['webp_upload_error'] = true;
     }
     // Check if AVIF images can be edited.
     if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' )
 ) ) {
         $plupload_init['avif_upload_error'] = true;
     }
 }
 }}}


 2. Block Editor path (wp-includes/rest-api/endpoints/class-wp-rest-
 attachments-controller.php):

 {{{
 if (
     $prevent_unsupported_uploads &&
     isset( $files['file']['type'] ) &&
     str_starts_with( $files['file']['type'], 'image/' )
 ) {
     // Check if the image editor supports the type.
     if ( ! wp_image_editor_supports( array( 'mime_type' =>
 $files['file']['type'] ) ) ) {
         return new WP_Error(
             'rest_upload_image_type_not_supported',
             __( 'The web server cannot generate responsive image sizes for
 this image. Convert it to JPEG or PNG before uploading.' ),
             array( 'status' => 400 )
         );
     }
 }
 }}}


 Difference between both:
 1. Media Library checks only WebP and AVIF specifically
 2. Block Editor checks all image types (anything starting with 'image/')
 3. Media Library sets a warning flag but allows upload
 4. Block Editor returns an error and prevents upload entirely


 This inconsistency causes SVG files to pass in the Media Library (where
 they're not specifically checked) but fail in the Block Editor (where all
 image/* types are checked).


 I’d love to hear your thoughts on this and discuss the best approach to
 resolving the inconsistency.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63302#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list