[wp-trac] [WordPress Trac] #50695: Make media_sideload_image extension list filterable

WordPress Trac noreply at wordpress.org
Sun Jul 19 02:30:27 UTC 2020


#50695: Make media_sideload_image extension list filterable
---------------------------+-----------------------------
 Reporter:  paulschreiber  |      Owner:  (none)
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Media          |    Version:
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 While `upload_mimes` is filterable and allows you to add additional items
 to the media library (i.e. SVGs), `media_sideload_image()` relies on an
 extension type check, and is not filterable.

 Current behaviour:
 {{{#!php
 <?php
 preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
 }}}


 Desired behaviour:
 {{{#!php
 <?php
 /**
  * Filters the file extensions used for media sideload.
  *
  * @since 5.5.0
  *
  * @param array $extensions The original extension list.
  */
 $allowed_extensions =  apply_filters( 'media_sideload_extensions',  array(
 'jpg', 'jpeg', 'jpe', 'png', 'gif' ) );
 preg_match( '/[^\?]+\.(' . join( '|', allowed_extensions ) . ')\b/i',
 $file, $matches );
 }}}

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


More information about the wp-trac mailing list