[wp-trac] [WordPress Trac] #36549: Space in attachment filename breaks srcset

WordPress Trac noreply at wordpress.org
Mon Apr 18 08:39:30 UTC 2016


#36549: Space in attachment filename breaks srcset
--------------------------+------------------------------
 Reporter:  underdude     |       Owner:  joemcgill
     Type:  defect (bug)  |      Status:  reviewing
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by underdude):

 Replying to [comment:2 joemcgill]:
 > Hi @underdude. Thanks for the report. I wonder if we should try to catch
 this when the file name is created rather than when we are generating
 'srcset' attributes.

 Yes, definitely that should be the primary way and that's what the default
 file upload process does. Since spaces (in addition to other special
 characters) in urls usually lead to problems later.

 In our case we had a lot of previously imported content where the files
 were imported using the `wp_insert_attachment` which leaves the filenames
 as they are and only creates the attachment objects to db. And everything
 was working fine before the responsive image update.

 It's also debatable that if this is a "user error", since processing the
 filenames to safe ones could be considered as something the developer
 should take care of when inserting attachments with `wp_insert_attachment`
 .

 The urls can be fixed using the `wp_calculate_image_srcset` filter, so in
 cases like ours, a core fix is not required to make things work again.

 We discussed this matter briefly with @nbachiyski on the WordCamp Finland
 Contributor Day and thought that if there is no side effects, this could
 be just a safety mechanism to prevent existing spaces in filenames not to
 break things even though the actual issue is somewhere else. Replacing
 spaces (or urlencoding the filename) is quite cheap operation afterall...

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


More information about the wp-trac mailing list