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

WordPress Trac noreply at wordpress.org
Fri Jul 18 01:16:43 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 rollybueno):

 == Reproduction Report
 === Description
 This report validates whether the issue can be reproduced.

 === Environment
 - WordPress: 6.8.1
 - PHP: 8.2.27
 - Server: nginx/1.26.1
 - Database: mysqli (Server: 8.0.35 / Client: mysqlnd 8.2.27)
 - Browser: Chrome 137.0.0.0
 - OS: Linux
 - Theme: Twenty Fifteen 4.0
 - MU Plugins: None activated
 - Plugins:
   * Safe SVG 2.3.1
   * Test Reports 1.2.0

 === Actual Results
 1.  ❎ Cannot reproduce.

 I came to this conclusion since the report stated that the code used
 `wp_get_attachment_image($image, $size, '', array('class' => 'mb-4',
 'height' => 60, 'width' => 60));` is working on WP v6.8.1.

 After using the same code with correct SVG attachment ID and empty `size`
 parameters, the `wp_get_attachment_image()` ignores the height & width in
 the `$attr` params even in 6.8.1.

 === Additional Notes
 - Downgraded to 6.8.1
 - Uses 2015 theme with only 2 plugins active
 - There's no additional filter manipulation, only the code provided
 - Uses same code provided by reporter `echo wp_get_attachment_image( 8,
 '', '', array( 'class' => 'mb-4', 'height' => 60, 'width' => 60 ) );`
 - The only difference are the 1st & 2nd parameters which are ID and size.
 - The WebP version ignores the height & width value but returns srcset for
 smaller device compatibility.
 - The SVG ignores the `height` and `width`

 ❗❗❗ The only time I was able to change the height and width value through
 `wp_get_attachment_image()` is when using `array( 60, 60 )` in the $size
 param, but it only works on normal images and not SVG.
 Code used: [[Image(https://i.imgur.com/r9FGUoI.png)]]

 Result: [[Image(https://i.imgur.com/UBfteHE.png)]]

 ❗❗❗We need more tester to try reproducing

 === Supplemental Artifacts
 Code used: [[Image(https://i.imgur.com/KJwsytc.png)]]
 ==== 6.8.1 ====
 WebP:
 Backend: Confirming we have WP v6.8.1
 [[Image(https://i.imgur.com/d6pO5aw.png)]]
 Frontend:
 [[Image(https://i.imgur.com/LOqrQGa.png)]]

 SVG:
 Backend:
 [[Image(https://i.imgur.com/OFgKLXQ.png)]]
 Frontend:
 [[Image(https://i.imgur.com/8dpCn77.png)]]

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


More information about the wp-trac mailing list