[wp-trac] [WordPress Trac] #60932: Remove PHP capability-block from uploading webp and avif

WordPress Trac noreply at wordpress.org
Fri Apr 5 01:30:30 UTC 2024


#60932: Remove PHP capability-block from uploading webp and avif
----------------------------+-----------------------------
 Reporter:  Cybr            |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Media           |    Version:
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Currently, WordPress wants the server to support editing of the image file
 types .webp and .avif before allowing them to be uploaded.

 This happens in `media_upload_form()`.

 {{{
 #!php
 // 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;
 }
 }}}

 Then, at `handler.js`, under a deprecated `jQuery.ready()` call, the
 errors are considered, and the entire upload is blocked.

 {{{
 #!js
 } else if ( file.type === 'image/webp' && up.settings.webp_upload_error )
 {
         // Disallow uploading of WebP images if the server cannot edit
 them.
         wpQueueError( pluploadL10n.noneditable_image );
         up.removeFile( file );
         return;
 } else if ( file.type === 'image/avif' && up.settings.avif_upload_error )
 {
         // Disallow uploading of AVIF images if the server cannot edit
 them.
         wpQueueError( pluploadL10n.noneditable_image );
         up.removeFile( file );
         return;
 }
 }}}

 Since images can still be served without editing them, this block should
 only be considered when actually editing the image.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60932>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list