We have a client that is wanting spaces replaced by hyphens rather than underscores, and otherwise Transliteration is perfect for the job. So having an alter hook to tie in options to rename the file name would be fantastic :)
Something like:
function transliteration_clean_filename($filename, $source_langcode = NULL) {
if (is_array($filename)) {
...
}
$original_filename = $filename;
$filename = transliteration_get($filename, '', $source_langcode);
...
drupal_alter('transliteration_clean_filename', $filename, $original_filename, $source_langcode);
return $filename;
Comments
Comment #1
alan d. commentedPatched and working example. Note, I ended up using a prepare as post-transliteration lost useful information. For example, the client used ampersands a lot, so I was replacing these with the word and.
File uploaded:
gg-Tvc-test chicken & veg pies-x3244325.jpg
File name after processing:
test-chicken-and-veg-pies.jpg
Comment #2
zterry95 commentedLooks like a very good feature.
Comment #3
mariusz.slonina commentedThank you!
Comment #4
amateescu commentedThe patch looks good to me as well, but we need to document it in a transliteration.api.php file :)
Comment #5
alan d. commentedAdded ;)
Comment #6
amateescu commentedCommitted and pushed to 7.x-3.x. Thanks!
Marking for backport to the 6.x branch.