[wp-trac] [WordPress Trac] #36822: srcset is added to <img /> even if media file is not present in media library

WordPress Trac noreply at wordpress.org
Sat May 21 14:47:03 UTC 2016


#36822: srcset is added to <img /> even if media file is not present in media
library
--------------------------+------------------------
 Reporter:  temmokan      |       Owner:  joemcgill
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  4.6
Component:  Media         |     Version:  4.4.1
 Severity:  normal        |  Resolution:
 Keywords:  responsive    |     Focuses:
--------------------------+------------------------
Changes (by joemcgill):

 * keywords:  responsive media => responsive
 * status:  reviewing => accepted
 * version:  4.5.2 => 4.4.1
 * milestone:  Awaiting Review => 4.6


Comment:

 Thanks for the explanation @temmokan. I've been able to confirm this
 behavior on my end. Looks like this is a result of the `src` matching
 pattern we added in r36121 being too permissive. The relevant code is
 here:


 {{{
 // If the file name is part of the `src`, we've confirmed a match.
 if ( ! $src_matched && false !== strpos( $image_src, $dirname .
 $image['file'] ) ) {
         $src_matched = true;
 }
 }}}

 This is matching a `src` with the metadata associated with the `id` found
 in the markup as long as the filenames match and the uploads directory
 structure is found somewhere in the path. We may need to check the full
 file path and not just the uploads directory path (i.e. the year/month
 part) in order to prevent false positives when the file has been moved out
 of the normal uploads directory location. However, we also need to be
 mindful about the need to support CDNs as outlined in #35102.

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


More information about the wp-trac mailing list