[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 28 03:56:06 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 has-patch needs-unit-     |     Focuses:
  tests                                          |
-------------------------------------------------+-------------------------

Comment (by azaozz):

 There are three requirements for srcset and sizes to be added to an image
 tag:
 - There should be a class name with the attachment post id in it. Example:
 `wp-image-4` means attachment id 4.
 - That id should be of an image attachment post (not page, not revision,
 etc.).
 - There should be image meta for that attachment post containing
 information about the sub-sizes that were generated when the image was
 uploaded.

 The `wp-image-###` class is only added when images are inserted from the
 media library. If the image tag is copied and then the src is changed, the
 class(es) on it would probably need changing or removing too.

 I also don't understand:
 >  `<img src="/wp-content/uploads/YYYY/MM/filename.png">` where the above
 file is *not* part of Media library

 What exactly is "not part of the media library"? There is no attachment
 post for it? Or there is no image meta? Or sub-sizes? Or all three? And
 why is that file in the media library directory?

 If any of the above, why the filename matches a file that is a part of the
 media library?

 Confusing :)

 In any case don't think this is a typical case that needs to be supported.
 The patch can break some CDNs that are working now.

 Perhaps we can add a filter on the filename matching so such "extreme"
 edge cases can be dealt with by a simple plugin? If I remember correctly
 we were discussing a filter there. At the end we decided against it as
 there weren't any reported problems that would have been solved by adding
 such filter.

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


More information about the wp-trac mailing list