[wp-trac] [WordPress Trac] #30180: wp_get_attachment_image_src does not return alt or meta

WordPress Trac noreply at wordpress.org
Wed Sep 18 22:22:02 UTC 2019


#30180: wp_get_attachment_image_src does not return alt or meta
-------------------------------------------------+-------------------------
 Reporter:  joedolson                            |       Owner:  antpb
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.3
Component:  Media                                |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests dev-        |     Focuses:
  feedback needs-dev-note                        |  accessibility
-------------------------------------------------+-------------------------

Comment (by antpb):

 After applying the patch, on line 1115 of media.php there is a reference
 to an undefined variable of `$src` This was causing a bunch of test
 failures. I'll be uploading a new patch with a fix. The object should now
 be `$image_attr['src']`

 I also noticed that the newly introduced tests are failing in the latest
 patch. I'll include a fix soon in my patch upload!


 {{{
 /var/www/tests/phpunit/tests/media/getAttachmentAttributes.php:103

 2)
 Tests_Media_GetAttachmentAttributes::test_should_return_attachment_attr_srcset
 Failed asserting that two strings are identical.
 --- Expected
 +++ Actual
 @@ @@
 -'http://example.org/wp-content/uploads/2019/18/canola-3.jpg 640w,
 http://example.org/wp-content/uploads/2019/18/canola-3-300x225.jpg 300w'
 +'http://example.org/wp-content/uploads/2019/09/canola-3.jpg 640w,
 http://example.org/wp-content/uploads/2019/09/canola-3-300x225.jpg 300w'

 }}}

 This is due to the date function used in the $expected variables:
 `$expected .= date( 'Y/j/');` The `j` was using the date instead of the
 month.

 Worth noting, I see 17 instances of the `wp_get_attachment_image_src()`
 here: https://github.com/WordPress/wordpress-
 develop/search?p=2&q=wp_get_attachment_image_src&unscoped_q=wp_get_attachment_image_src

 In the above discussions, we deemed the deprecating the old function to be
 in scope of this ticket. One instance of it is in deprecated.php and is an
 older function that recommends using `wp_get_attachment_image_src()` I'll
 be sure to update that as well to recommend new function introduced with
 this ticket.

 I have some concerns about making the changes to the ~16 other instances
 in Core (including various default themes). I'm completely on board with
 implementing the changes to ensure Core uses the new function, however, I
 must warn that being so close to beta 1, I don't feel confident that this
 patch should land for 5.3 without enough testing. I'm also not a fan of
 deprecating and having notices violating in Core. If we remove deprecation
 from the scope, I feel a lot better with committing this before 5.3 beta
 1.

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


More information about the wp-trac mailing list