[wp-trac] [WordPress Trac] #24251: Reconsider SVG inclusion to get_allowed_mime_types

WordPress Trac noreply at wordpress.org
Thu Apr 3 12:35:47 UTC 2025


#24251: Reconsider SVG inclusion to get_allowed_mime_types
-------------------------------+------------------------------
 Reporter:  JustinSainton      |       Owner:  (none)
     Type:  enhancement        |      Status:  reopened
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Upload             |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  early 2nd-opinion  |     Focuses:
-------------------------------+------------------------------

Comment (by sonaliprajapati):

 add below code

 // Allow SVG Uploads
 function allow_svg_uploads($mimes) {
     $mimes['svg'] = 'image/svg+xml';
     return $mimes;
 }
 add_filter('upload_mimes', 'allow_svg_uploads');

 // Sanitize SVG Before Upload
 function sanitize_svg_check($file) {
     if ($file['type'] === 'image/svg+xml') {
         $file['ext']  = 'svg';
         $file['type'] = 'image/svg+xml';
     }
     return $file;
 }
 add_filter('wp_check_filetype_and_ext', 'sanitize_svg_check', 10, 4);

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


More information about the wp-trac mailing list