[wp-trac] [WordPress Trac] #48453: Regression: Implied contract between image sub-size filenames and their base filename now broken

WordPress Trac noreply at wordpress.org
Tue Oct 29 22:54:26 UTC 2019


#48453: Regression: Implied contract between image sub-size filenames and their
base filename now broken
-------------------------------------+---------------------
 Reporter:  ianmjones                |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  5.3
Component:  Media                    |     Version:  trunk
 Severity:  major                    |  Resolution:
 Keywords:  needs-patch 2nd-opinion  |     Focuses:
-------------------------------------+---------------------

Comment (by azaozz):

 After quite a bit of testing thinking that the problem reported here would
 be fixed best by updating/extending the DB query when looking at
 `_wp_attached_file` meta values.

 Trying to guess the attachment ID from an image URL has always been a hit-
 and-miss process. Ideally there should be no need for that, but... some
 themes and plugins are not using the WP functions and "doing-it-wrong".
 Adding a (somewhat standardized) function to handle this in core seems to
 make most sense (yeah, it means that yet again core will be fixing the
 "doing-it-wrong" practices in themes and plugins...).

 For an image named `landscape.jpg` currently the value in
 `_wp_attached_file` may be `landscape.jpg`, `landscape-scaled-####.jpg` or
 `landscape-rotated.jpg`. Thinking that removing the variable `-####` bit
 from the file name for scaled images, and updating the DB query to do

 {{{
 WHERE ( meta_value='landscape.jpg' OR meta_value='landscape-scaled.jpg' OR
 meta_value='landscape-rotated.jpg' )
 }}}

 would be the most straightforward fix here.

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


More information about the wp-trac mailing list