When using the transliteration function for file uploads, an original space character gets replaced by underscore. This seems to be hardcoded.
It would be fine if one could define its own separator character and omission rules for file renamings (as for the URL aliases) or to have a setting, which allows to use the same rules for both.
Because eventually files will also be referred by URLs! And wouldn't it be nice to have the same universal separator throughout your whole site for both URL aliases and filenames (which eventually also get URLs somewhere)? Example: "/my-little-node" and "/files/my-little-file.txt".
Original: Aaa Bbb Ccc.txt
Result: aaa_bbb_ccc.txt
Expected: aaa-bbb-ccc.txt
Comment | File | Size | Author |
---|---|---|---|
#5 | transliteration-spaces-973936-5.patch | 2.34 KB | imclean |
Comments
Comment #1
eL CreditAttribution: eL commented+1
Comment #2
Slovak CreditAttribution: Slovak commentedYou could edit line 82 of transliteration.module to read:
$filename = str_replace(' ', '-', $filename);
The difference being in the str_replace from '_' to '-'
Perhaps if function transliteration_clean_filename would have another variable that could be set in template.php which would define the character to use for replacement in filenames?
Comment #3
mibfire CreditAttribution: mibfire commented+1
Comment #4
sachbearbeiter CreditAttribution: sachbearbeiter commented+1
Comment #5
imclean CreditAttribution: imclean commentedGood idea. Here's a patch which provides some configuration options regarding spaces. It defaults to the current behaviour, with options to keep spaces, remove them altogether, or replace them with either an underscore or dash character.
Comment #6
roball CreditAttribution: roball commentedThis is a duplicate of #862248: Option to keep space. Please post patches there.
Comment #7
imclean CreditAttribution: imclean commentedTrue yours is an earlier issue, however the patch addresses this issue more closely so this is where I've posted it.
I'd rather not upload it to multiple issues. Please try it out and provide feedback.
Comment #9
durum CreditAttribution: durum commentedsub
Comment #10
imclean CreditAttribution: imclean commented#862248: Option to keep space