Problem/Motivation
When upload file with a long name (name does not contain spaces) via the file widget then the file name displayed in a single line and page markup looks like broken (al least a horizontal scroll shows up):

Proposed resolution
Add the wbr tag after each underscores in the file name:

User interface changes
Add the Break row checkbox to the field manage page:

| Comment | File | Size | Author |
|---|---|---|---|
| #15 | long-file-name-3157015-15.patch | 3.29 KB | ohorbatiuk |
Comments
Comment #2
ohorbatiukComment #3
chi commentedThis won't work if words in a file name are separated by dashes or any other characters. I think it would be much easier to limit the width using CSS max-width or text-overflow properties.
Comment #4
ohorbatiukI do not think showing only part of the file name is a good idea. Also, in my case need to display the full filename.
When words are separated by dashes or spaces then this patch is not needed because a bug is not reproducible:

Comment #5
ohorbatiukComment #6
tripurari commented@chmez, Issue is still reproducible on Drupal 7 using underscore and same is not reproducible by using spaces in the uploaded file without applying Patch as per #4. Please find the Screenshot for your reference.
Comment #7
tripurari commentedComment #8
tripurari commentedComment #9
tripurari commentedPlease ignore Comment was trying to add Organization name by mistake comment was added.
Comment #10
charles belovI don't believe we can assume the file name will contain specific characters such as an underscore. A file name such as QwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwertyQwerty.pdf is perfectly legitimate and would not be rescued by this patch.
I suggest just adding the style:
word-break: break-all;
Comment #11
charles belovComment #12
ohorbatiuk@charles-belov, I don't agree with you because most of the software suggests using human-readable file names (words separated by spaces) which converts by Drupal (replace spaces by underscores).
Comment #13
charles belovWe have no control over what file names people upload. There is nothing preventing them from uploading file names that are just a long random string of alphanumeric characters. Even if that's not a best practice, there is no reason I can think of to create a solution that breaks in such cases, when a solution that works in all cases exists.
Comment #14
chi commentedAgree #13. The way users name their files is beyond our control.
Comment #15
ohorbatiukComment #16
poker10 commentedThanks for reporting and working on this @chmez!
I think that the solution which will work with all possible filenames would be better, as mentioned in #13. What are the cons of using
word-break: break-all;? It could be even less "intrusive" change in comparision with adding a new checkbox to the file field configuration.Drupal 7 does not have such conversion in the core - do you meant the Transliteration module? We cannot assume that sites will have this module installed. If you upload a file with spaces on vanilla D7 core to the file field, then nothing is changed and the filename is kept as it is.