3

I need to clean up file names on upload. Both for image fields, other file fields and IMCE file manager. The transliteration module is not yet ported to Drupal 8 and the community does not seem to agree on how to implement the core transliteration in Drupal 8.

Do I have to make a custom module for this, or is there a simpler way?

Right now, Drupal 8 seems to allow both spaces and special characters in filenames. I know about the module File (Field) Paths, but it will have to be set up for every file field on every content type. I don't think it will work with IMCE.

0

4 Answers 4

3

It seems that the module already mentioned is now covered by Drupals security advisory policy:

Transliterate filenames for uploads - https://www.drupal.org/project/transliterate_filenames

Stable releases for this project are covered by the security advisory policy.

8.x-1.3 Stable release covered by the Drupal Security Team released 1 July 2019

2

I applied a Drupal 8 core patch from this page. It seems to work fine. It adds a new option to /admin/config/media/file-system: File transliteration option Drupal 8

This option enables transliteration for all future uploads to all file fields. It also works for inline images when Enable image uploads is enabled (for the text-format). I don't know if the patch affects IMCE, since IMCE was not installed on my test installation.

2

There is a module for that https://www.drupal.org/project/transliterate_filenames

Transliteration for all uploading files (includes fields and ckeditor inline upload)

How to use: just enable module as usual. All new file names will be transliterate to Latin characters.

2
  • This project is not covered by Drupal’s security advisory policy.
    – eye-wonder
    Oct 17, 2018 at 13:13
  • The module is stable now and it works: 1.It replaces spaces in file names 2.Adds a counter for duplicate files. Apr 6, 2020 at 8:29
0

Just use this module. This module is based on the blog post by Alexander Belov, but simplified for a less specific use case. https://drupal.org/project/filename_transliteration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.