[wp-trac] [WordPress Trac] #39768: Incorrect image returned with attachment_url_to_postid()

WordPress Trac noreply at wordpress.org
Thu Feb 2 18:52:16 UTC 2017


#39768: Incorrect image returned with attachment_url_to_postid()
--------------------------+------------------------------
 Reporter:  ben.greeley   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  4.7.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by ben.greeley):

 @tristangemus thanks for the prompt response. The use case is one image
 was named Unknown.jpg that was uploaded to a site. Later, unknown.jpg was
 added to the media library, specifically these two images:
 http://www.lamag.com/wp-content/uploads/sites/9/2017/01/Unknown.jpg and
 http://www.lamag.com/wp-content/uploads/sites/9/2017/01/unknown.jpg . When
 the full image is embedded onto a post, we have a link like <img
 class="aligncenter wp-image-671724 size-full" src="http://www.lamag.com
 /wp-content/uploads/sites/9/2017/01/unknown.jpg" />

 There is some code that runs  attachment_url_to_postid(
 'http://www.lamag.com/wp-content/uploads/sites/9/2017/01/unknown.jpg' ),
 but the image that it returns is a reference to http://www.lamag.com/wp-
 content/uploads/sites/9/2017/01/Unknown.jpg . It appears this is happening
 because the table already has one value of 2017/01/Unknown.jpg, which
 matches its SQL query trying to find 2017/01/unknown.jpg since mySQL
 queries aren't case-sensitive.

 I'm able to reproduce in my local environment.

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


More information about the wp-trac mailing list