function transliterate_filenames_transliteration in Transliterate filenames for uploads 8
Implements callback for hook_file_validate().
1 call to transliterate_filenames_transliteration()
File
- ./
transliterate_filenames.module, line 38 - Contains transliterate_filenames.module.
Code
function transliterate_filenames_transliteration($filename) {
$filename = \Drupal::service('transliterate_filenames.sanitize_name')
->sanitizeFilename($filename);
// For empty.
$name = explode('.', $filename);
$name = reset($name);
$extension = explode(".", $filename);
$extension = end($extension);
// Is empty.
if (!$name) {
$filename = md5(rand()) . '.' . $extension;
}
return $filename;
}