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
CommentFileSizeAuthor
#5 transliteration-spaces-973936-5.patch2.34 KBimclean
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eL’s picture

+1

Slovak’s picture

You 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?

mibfire’s picture

+1

sachbearbeiter’s picture

+1

imclean’s picture

Version: 6.x-3.0 » 6.x-3.x-dev
Status: Active » Needs review
FileSize
2.34 KB

Good 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.

roball’s picture

Status: Needs review » Closed (duplicate)

This is a duplicate of #862248: Option to keep space. Please post patches there.

imclean’s picture

Status: Closed (duplicate) » Needs review

True 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.

durum’s picture

sub

imclean’s picture

Status: Needs review » Closed (duplicate)