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

WordPress Trac noreply at wordpress.org
Sat Apr 16 11:59:33 UTC 2016


#36549: Space in attachment filename breaks srcset
--------------------------+-----------------------------
 Reporter:  underdude     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 By default spaces in filenames are replaced with dashes on upload phase by
 `sanitize_file_name`, but if you create the attachments some other way,
 e.g. with `wp_insert_attachment`, the filenames stay untouched.

 As the srcset syntax needs spaces to separate things, a space in filename
 breaks the whole srcset. Chrome gives you a `Failed parsing 'srcset'
 attribute value since it has an unknown descriptor.` in dev tools console.

 This is obviously an edge case since attachment filenames shouldn't have
 spaces in the first place.

 This can be fixed by replacing spaces when generating image urls for the
 srcset.

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


More information about the wp-trac mailing list