[wp-trac] [WordPress Trac] #51058: attachment_url_to_postid does not retrieve post ID of really large images

WordPress Trac noreply at wordpress.org
Tue Nov 3 17:26:45 UTC 2020


#51058: attachment_url_to_postid does not retrieve post ID of really large images
-----------------------------+------------------------------
 Reporter:  littler.chicken  |       Owner:  (none)
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Media            |     Version:  5.3
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------
Changes (by metalandcoffee):

 * version:  trunk => 5.3


Comment:

 I was able to reproduce this issue.

 Appending `-scaled` to an oversized PNG images was introduced in 5.3
 (https://core.trac.wordpress.org/ticket/48736).

 The function `attachment_url_to_postid` is simply doing a check against
 the database with whichever url you give it:


 {{{#!php
 $sql = $wpdb->prepare(
 "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key =
 '_wp_attached_file' AND meta_value = %s", $path );
 }}}

 So it makes sense that it'll return nothing since the file was immediately
 renamed upon upload.

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


More information about the wp-trac mailing list