[wp-trac] [WordPress Trac] #41816: attachment_url_to_postid() should find post_id for URLs of intermediate size images

WordPress Trac noreply at wordpress.org
Wed Sep 6 15:40:47 UTC 2017


#41816: attachment_url_to_postid() should find post_id for URLs of intermediate
size images
--------------------------+-----------------------------
 Reporter:  pbiron        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 [[https://developer.wordpress.org/reference/functions/attachment_url_to_postid/|attachment_url_to_postid()]]
 fails to find the post ID when given a URL of an intermediate sized image.

 For example,

 {{{
 $url_of_full_sized_image = 'http://example.com/wp-
 content/uploads/test.jpg';
 $attachment_id = attachment_url_to_postid( $url_of_full_sized_image );
 // $attachment_id now equals 3

 $url_of_intermediate_sized_image = 'http://example.com/wp-content/uploads
 /test-150x150.jpg';
 $attachment_id = attachment_url_to_postid(
 $url_of_intermediate_sized_image );
 // $attachment_id now equals 0 but should equal 3, the same as for the
 full-sized image
 }}}

 This should be fixed.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41816>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list