I have a file with a filename which has a double underscore in it. When Drupal saves the file, it shortens it to be only one. ie:


When Drupal saves the file, it removes one of the underscores and names it this:


Where does Drupal do this? I need to account for any changes which Drupal makes to the filename and I need to know what other characters it may remove etc.


You can use transliteration module.

and in code use code like

function hook_transliteration_clean_filename_prepare_alter(&$filename, $source_langcode) {
  $filename = drupal_strtolower($filename);
  $filename = str_replace('__','_', $filename);

Above code is not tested, Hope it will help you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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