[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 11:10:33 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: | Focuses:
--------------------------+---------------------
Comment (by shreya0shrivastava):
I was able to reproduce the bug following the steps mentioned by
@rainbowgeek
== Reproduction Report
=== Description
This report validates whether the issue can be reproduced.
=== Environment
- WordPress: 6.8.1, 6.8.2
- PHP: 8.2.23
- Server: nginx/1.26.1
- Database: mysqli (Server: 8.0.35 / Client: mysqlnd 8.2.23)
- Browser: Chrome 138.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.0
- MU Plugins:
* test 1 (contains code to allow SVG)
- Plugins:
* Test Reports 1.2.0
=== Actual Results
1. ✅ Error condition occurs (reproduced).
=== Steps for reproduction
1. Add a mu-plugin with the following code:
{{{#!php
<?php
add_filter('upload_mimes', function($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
});
}}}
2. Go to the Media Library and upload an SVG file. Note its attachment ID.
3. In your theme’s `functions.php`, add:
{{{#!php
<?php
add_action('wp_head', function() {
echo wp_get_attachment_image(ATTACHMENT_ID, 'full', '', array(
'class' => 'mb-4',
'height' => 240,
'width' => 240
));
});
}}}
Replace `ATTACHMENT_ID` with the actual SVG attachment ID.
4. Visit the frontend and inspect the rendered `<img>` tag in the browser.
5. Check for both WP 6.8.1 and WP 6.8.2
=== Additional Notes
- Height and width attributes show up on using WP 6.8.1
- Height and width attributes do not show up on using WP 6.8.2
- The same code was used to add SVG for both WP versions
=== Supplemental Artifacts
For WP 6.8.1
[[Image(https://i.ibb.co/9kWHbXzK/Screenshot-2025-07-22-at-4-11-36-PM.png)]]
For WP 6.8.2
[[Image(https://i.ibb.co/Rp3464cR/Screenshot-2025-07-22-at-4-17-43-PM.png)]]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63714#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list