2

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:

Snapshot__john_doe_2_opt.jpg

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

Snapshot_john_doe_2_opt.jpg

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.

2

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.

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.