[wp-trac] [WordPress Trac] #14110: Expose height and width attributes to 'wp_get_attachment_image_attributes' filter

WordPress Trac noreply at wordpress.org
Mon Jun 23 09:41:00 UTC 2025


#14110: Expose height and width attributes to 'wp_get_attachment_image_attributes'
filter
-------------------------------------------------+-------------------------
 Reporter:  divinenephron                        |       Owner:
                                                 |  adamsilverstein
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.8.2
Component:  Media                                |     Version:  3.0
 Severity:  minor                                |  Resolution:
 Keywords:  has-patch commit has-unit-tests      |     Focuses:
  has-test-info                                  |
-------------------------------------------------+-------------------------
Changes (by sandeepdahiya):

 * keywords:  has-patch commit has-unit-tests => has-patch commit has-unit-
     tests has-test-info


Comment:

 == Test Report
 === Description
 ✅ This report validates that the indicated patch works as expected.

 Patch tested: [https://github.com/WordPress/wordpress-
 develop/pull/8758.diff Patch-8758.diff]

 === Environment
 - WordPress: 6.9-alpha-60093-src
 - PHP: 8.2.28
 - Server: nginx/1.27.5
 - Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
 - Browser: Firefox 139.0
 - OS: Windows 10/11
 - Theme: Twenty Twenty-Five 1.2
 - MU Plugins: None activated
 - Plugins:
   * Image Attributes Debugger 1.0
   * Test Reports 1.2.0

 === Actual Results
 1.  Before the patch - for `wp_get_attachment_image_attributes`
 [https://ibb.co/QvHYSTQR attributes passed to the filter]: -

 {{{
 Image attributes passed to the filter:
 Array
 (
     [src] => http://localhost:8889/wp-content/uploads/2025/06/oscar-
 sutton-yihlaRCCvd4-unsplash-200x300.jpg
     [class] => attachment-medium size-medium
     [alt] =>
     [srcset] => http://localhost:8889/wp-content/uploads/2025/06/oscar-
 sutton-yihlaRCCvd4-unsplash-200x300.jpg 200w, http://localhost:8889/wp-
 content/uploads/2025/06/oscar-sutton-yihlaRCCvd4-unsplash-684x1024.jpg
 684w, http://localhost:8889/wp-content/uploads/2025/06/oscar-sutton-
 yihlaRCCvd4-unsplash-768x1150.jpg 768w, http://localhost:8889/wp-
 content/uploads/2025/06/oscar-sutton-yihlaRCCvd4-unsplash-1025x1536.jpg
 1025w, http://localhost:8889/wp-content/uploads/2025/06/oscar-sutton-
 yihlaRCCvd4-unsplash-1367x2048.jpg 1367w, http://localhost:8889/wp-
 content/uploads/2025/06/oscar-sutton-yihlaRCCvd4-unsplash-scaled.jpg 1709w
     [sizes] => (max-width: 200px) 100vw, 200px
 )
 }}}


 2.  After the patch - [https://ibb.co/RTLJmBsz attributes passed to the
 filter] :-

 {{{
 Image attributes passed to the filter:
 Array
 (
     [src] => http://localhost:8889/wp-content/uploads/2025/06/oscar-
 sutton-yihlaRCCvd4-unsplash-2-200x300.jpg
     [class] => attachment-medium size-medium
     [alt] =>
     [width] => 200
     [height] => 300
     [srcset] => http://localhost:8889/wp-content/uploads/2025/06/oscar-
 sutton-yihlaRCCvd4-unsplash-2-200x300.jpg 200w, http://localhost:8889/wp-
 content/uploads/2025/06/oscar-sutton-yihlaRCCvd4-unsplash-2-684x1024.jpg
 684w, http://localhost:8889/wp-content/uploads/2025/06/oscar-sutton-
 yihlaRCCvd4-unsplash-2-768x1150.jpg 768w, http://localhost:8889/wp-
 content/uploads/2025/06/oscar-sutton-yihlaRCCvd4-unsplash-2-1025x1536.jpg
 1025w, http://localhost:8889/wp-content/uploads/2025/06/oscar-sutton-
 yihlaRCCvd4-unsplash-2-1367x2048.jpg 1367w, http://localhost:8889/wp-
 content/uploads/2025/06/oscar-sutton-yihlaRCCvd4-unsplash-2-scaled.jpg
 1709w
     [sizes] => (max-width: 200px) 100vw, 200px
 )
 }}}



 === Unit test report: -


 {{{
 $ npm run test:php -- --group 14110

 > WordPress at 6.9.0 test:php
 > node ./tools/local-env/scripts/docker.js run --rm php
 ./vendor/bin/phpunit --group 14110

 Installing...
 Running as single site... To run multisite, use -c
 tests/phpunit/multisite.xml
 Not running ajax tests. To execute these, use --group ajax.
 Not running ms-files tests. To execute these, use --group ms-files.
 Not running external-http tests. To execute these, use --group external-
 http.
 PHPUnit 9.6.23 by Sebastian Bergmann and contributors.

 Warning:       Your XML configuration validates against a deprecated
 schema.
 Suggestion:    Migrate your XML configuration using "--migrate-
 configuration"!

 ...                                                                 3 / 3
 (100%)

 Time: 00:07.222, Memory: 191.00 MB

 OK (3 tests, 8 assertions)
 }}}

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


More information about the wp-trac mailing list