[wp-trac] [WordPress Trac] #63714: Missing width/height attributes on SVG file since WP 6.8.2

WordPress Trac noreply at wordpress.org
Tue Jul 22 13:54:01 UTC 2025


#63714: Missing width/height attributes on SVG file since WP 6.8.2
--------------------------+---------------------
 Reporter:  rainbowgeek   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  6.8.3
Component:  Media         |     Version:  6.8.2
 Severity:  major         |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+---------------------
Changes (by rollybueno):

 * keywords:   => needs-patch


Comment:

 Thank you! This filter `upload_mimes` is the missing piece to reproduce,
 and I was able to do that after adding that filter.
 {{{
 function wp_mime_types($mimes) {
         $mimes['svg'] = 'image/svg+xml';
         return $mimes;
 }
 add_filter('upload_mimes', 'wp_mime_types');
 }}}

 **6.8.1**:
 [[Image(https://i.imgur.com/CAU1xPr.png)]]

 **6.8.2**
 [[Image(https://i.imgur.com/lWFhq5B.png)]]

 Replying to [comment:7 rainbowgeek]:
 > Use this code to allow SVG in a mu-plugin (not Safe SVG plugin):
 >
 > {{{
 > function wp_mime_types($mimes) {
 >       $mimes['svg'] = 'image/svg+xml';
 >       return $mimes;
 > }
 > add_filter('upload_mimes', 'wp_mime_types');
 > }}}
 >
 > Then upload a SVG file to the media library, pass the attachment ID to
 the $image variable:
 >
 > {{{
 > wp_get_attachment_image(1, 'full', '', array('class' => 'mb-4', 'height'
 => 60, 'width' => 60));
 > }}}
 >
 > Echo it in your theme somewhere (eg: functions.php with the code below).
 >
 >
 > {{{
 >  add_action('wp_head', function() {
 >       echo wp_get_attachment_image(7, 'full', '', array('class' =>
 'mb-4', 'height' => 60, 'width' => 60));
 >  });
 > }}}
 >
 > Result with WP 6.8.2:
 > {{{
 > <img src="http://test.local/wp-content/uploads/2025/07/ico-
 newsletter.svg" class="mb-4" alt="" decoding="async" loading="lazy">
 > }}}
 >
 >
 > Result with WP 6.8.1:
 >
 >
 > {{{
 > <img src="http://test.local/wp-content/uploads/2025/07/ico-
 newsletter.svg" class="mb-4" alt="" height="60" width="60"
 decoding="async" loading="lazy">
 > }}}

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


More information about the wp-trac mailing list