Currently, when the "Transliterate file names during upload." checkbox is ticked at admin/settings/file-system, all whitespace characters will be replaced by an underline (_) character. Can we please have a checkbox that allows unticking that behaviour? More than one spaces side by side should still be reduced to a single one, but if you are using "pretty" self-explaining filenames for files that are attached to a node, spaces look prettier than underlines, so it would be nice NOT to force replacing by an underline.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dbetschart’s picture

Version: 6.x-3.0 » 5.x-2.1

Same problem here with 5.x version..

roball’s picture

Version: 5.x-2.1 » 6.x-3.0

I think it's better to keep the version at the highest one having this problem.

smk-ka’s picture

Anyone up for a patch?
- Add a checkbox to the settings.
- Check its value when processing a filename.

imclean’s picture

roball’s picture

I have marked the other node as duplicate of this one.

imclean’s picture

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

Repost from http://drupal.org/node/973936#comment-4668844

This patch 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.

imclean’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
FileSize
2.31 KB

Patch also applies to D7 version. This one's cleaned up slightly.

amateescu’s picture

FileSize
10.08 KB

There was another issue that requested to have this setting for the '@' character, and probably more will come, so how about we deal with all of them in a single patch?

chianti’s picture

Thank you for working on this. Could we keep brackets too?

I often name my downloadable documents in the format:
[name with spaces] [Version Number] (last updated date).pdf

amateescu’s picture

Have you tested the patch? There's an option for brackets too..

smitty’s picture

Any chance to get this into the next release?

BrightBold’s picture

Before this patch, my white spaces were getting replaced with underscores when I wanted hyphens. With the patch, and with the preferred separator set to "-" and my Spaces set to "replace by separator," the space is removed but not replaced. Same result if I set it to "no action (do not replace)." Things other than spaces seem to be converted properly.

I had to apply much of the patch by hand, as it didn't apply cleanly (being almost a year old), so maybe I missed something? (Although I've double-checked and can't figure out what.) Could someone re-roll for the latest version?

johnv’s picture

Attached patch is an update of #8. It is D7-only, as #8 is.

As reported in #12, 'space' handling wasn't working. That is added. The patch contained a '\s' (whitespace like space, tab, ..). I left that one in.

Chris Matthews’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll, +Needs rework

The 6 year old patch in #13 does not apply to the latest 7.x-3.x dev snapshot and is probably too old to reroll, but I went ahead and tagged the issue accordingly.

Checking patch transliteration.inc...
Hunk #1 succeeded at 208 (offset 3 lines).
Checking patch transliteration.install...
error: while searching for:
function transliteration_uninstall() {
  variable_del('transliteration_file_uploads');
  variable_del('transliteration_file_lowercase');
  variable_del('transliteration_search');
}

error: patch failed: transliteration.install:29
error: transliteration.install: patch does not apply
Checking patch transliteration.module...
error: while searching for:
    '#default_value' => variable_get('transliteration_file_lowercase', TRUE),
    '#description' => t('This is a recommended setting to prevent issues with case-insensitive file systems. It has no effect if transliteration has been disabled.'),
  );
  $form['buttons']['#weight'] = 1;
}

/**

error: patch failed: transliteration.module:53
error: transliteration.module: patch does not apply
dakruchko’s picture

I think we can use hook_transliteration_clean_filename_prepare_alter() in order to replace spaces with hyphens, and then it will be cleaned and sanitized as usual