Speedup WordPressFilenames to latinDonateview source
Plugin helps you convert cyrillic (russian, ukrainian, belorussian), german, polish, spanish and other filenames to latin in your media library during upload.
List of sanitizing letters: а б в г д е ж з и й к л м н о п р с т у ф х ц ч ш щ ь ю я ґ є і ї ё ы ъ э ў ą ć ę ł ń ó ś ź ż à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö × ø ù ú û ü ý þ ÿ ß ő ű ě š č ř ž ý á é ď ť ň ú ů α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ω ά έ ή ί ό ύ ώ ς ΐ ϊ ϋ ΰ.
Convert filenames to lowercase automatically.
Feature request: Batch rename already uploaded files. Please. PLEASE! :)
I was quite surprised there is no such plugin yet....
It's 2014 and the bug in OS X Firefox (current 32.0.1) still exist :(
Any ideas for a solution?
The only suggestion - try to use Chrome or Safari.
Hi, I would like to thank you for great plugin. I use them in Czech languge websites, so I can share my transcode array with you and other users:
'/ě/','/š/','/č/','/ř/','/ž/','/ý/','/á/','/é/','/ď/','/ť/','/ň/','/ú/','/ů/', // czech
'/Ě/','/Š/','/Č/','/Ř/','/Ž/','/Ý/','/Á/','/É/','/Ď/','/Ť/','/Ň/','/Ú/','/Ů/'
TO:
'e','s','c','r','z','y','a','e','d','t','n','u','u', //czech
'e','s','c','r','z','y','a','e','d','t','n','u','u'
Regards,
Jiri
Thank you very much for this great feedback.
I updated Filenames-to-latin plugin with your code. Please write me back if you will find some bugs.
P.S. I mentioned you in changelog.
Hi,
thanks for the Plugin. I suggest the following update and would love for you to issue an updated version of the plugin.
In German, the correct transliteration for the "umlauts" is not a/o/u/s but rather ae/oe/ue/ss.
Hence i updated the code by uncommenting the german section and changing the lower part to:
'ae','ae','oe','oe','ue','ue','ss', // german.
Also, the the correct transliteration for some of the swedish/danish letters is also not correct except for one, the combined AE that is correctly transliterated into AE.
Just before the AE is an A with an O on top that is AFAIK more correctly represented with an ao and the O with a dash throuh it is similar to the german o with two dots above it, so an oe would be more suitable.
But best to aks a native, i can only vouch for the german :-)
Thank you very much for the feedback.
I updated the Filenames-to-latin plugin and fixed german letters sanitizing.
Write me back please if you will find some bugs.
I didn't fix danish and sweden letters because I need to hear the thought of native speaker about that.
P.S. I mentioned you in the changelog section.
Hello again.
When I upload files by Gallery Plugin the ones containing special characters in their filenames are not saved. I am not sure on which side there could be some issue but maybe someone has the similar problem?
I use version 1.3 on WordPress 3.4.1. When I upload file with polish letters from Windows, everything goes correct, but when uploading from MacOS I noticed the letter "ą" was not changed. Anyone familiar with similar behavior?
Does the other unique polish letters (ćęł...) convert correctly?
In which browser does this happen?
Did you tried to upload on MacOS on other browser?
I checked it out again on Windows 7 latest IE - it works (every polish special sign is replaced). The same on Windows/Firefox. On MacOS on the other hand, with Firefox 15.0.1 it does not - none of the special characters were replaced (only uppercases were replaced by lowercases). I checked out Safari 6.0 on MacOS and it works without problems.
It is the bug of Firefox on MacOS. Firefox converts filenames very strange. For example "é" becomes "é". I hope Firefox developers will fix this bug in future releases.
I submitted this into bugzilla.
:) I found the cheese ! :)
question: - would you build a plugin from its source code?
"
function correctFileName($string) // Remove accents, swap space.
{
// change accents to latin http://weblabor.hu/levlistak/wl-phplista/2006/08/051534
$accentuatedLetters = array('é' => 'e', 'á' => 'a', 'u' => 'u', 'o' =>
'o', 'ú' => 'u', 'ö' => 'o', 'ü' => 'u', 'ó' => 'o');
foreach ($accentuatedLetters as $key => $value)
{
$string = str_replace($key, $value, $string);
}
// Space removal
$string = str_replace(' ', '_', $string);
// make lowercase
$string = strtolower($string);
return $string;
}
"
Thx, Zoltan
These letters (éáuoúöüó) are already sanitizing into their latin analogs as you wrote.
You may download and test plugin with different filenames and please write ma back if you will find a bug.
Hey.
I only read yet, but I will love it I guess :)
A question - your plug-in could remove or change the "spaces" in the filenames to dash or underscore, and make them lowercase?
eg.:
" idiot Windows FILEnames.jpg "
-->
"nice_windows-filenames.jpg"
Thx, Zoltan
" idiot Windows FILEnames.jpg " will become "idiot-windows-filenames.jpg". So the spaces will be replaced with dashes "-" and filename will be lowercased.
Hi, thanks a lot for the plugin. However it doesn't work with accents conversion on FireFox. You should check this out :)
Please send me the filename with which you had a problem.
And also what version of WordPress and Firefox and OS are you using?
FireFox 10; WordPress 3.3.1; OSX Leopard & Lion;
Filename: "capture-décran.jpg".
I wrote another approach that fixes my problem (directly in functions.php)
Capture d’écran 2012-01-09 à 21.21.38.png => capture-decran-2012-01-09-a-21-21-38.png
function sanitize_filename_on_upload($filename) {
$ext = end(explode('.',$filename));
// Replace all weird characters
$sanitized = preg_replace('/[^a-zA-Z0-9-_.]/','', substr($filename, 0, -(strlen($ext)+1)));
// Replace dots inside filename
$sanitized = str_replace('.','-', $sanitized);
return strtolower($sanitized.'.'.$ext);
}
add_filter('sanitize_file_name', 'sanitize_filename_on_upload', 10);
Maybe this can help. I am only concerned in sanitizing "éàç" characters that might be used as filenames her in France, i don't know about other alphabets.
Anyway, i just wanted to warn you about this bug.
Your code looks good to me too, i don't understand, maybe wordpress overwrites or encodes some characters before your process and "é" is not recognized because it's converted as "é" ?
Merci Édouard!