2

Why when I upload a picture with its name with international characters, like: ábc.jpg to WordPress, the File name appears as: bc.jpg?

Instead, its Title and URL are correct. Please, see this screen capture: http://d.pr/i/1oFG

Is this a bug?

P/S: Please, PAY ATENTION that this behavior only occurs with images that the international character is the FIRST letter of its name, and NOT when are in the middel of the name.

  • 1
    what version of WordPress and PHP are you using? – Milo Feb 17 '13 at 15:51
  • This is under WP 3.5.1 and PHP 5.3.3-7+squeeze14 – vicmarto Feb 17 '13 at 16:25
1

That is a bit odd, and I can't reproduce your error. Perhaps it has something to do with differnt character encodings of the filename/filesystem you are uploading from or to. When handling file uploads WordPress sanitizes the file name to remove spaces and some other unwanted characters. This sanitizing is performed by sanitize_file_name when the upload completes. The first part (and integral) of which looks like this:

$filename_raw = $filename;
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
$special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
$filename = str_replace($special_chars, '', $filename);
$filename = preg_replace('/[\s-]+/', '-', $filename);
$filename = trim($filename, '.-_');

As you can see the array $special_chars does contain the grave accent, but not the acute accent. I see no reason why this code would filter out the á character (unless you have some plugin installed that's hooking into sanitize_file_name_chars or sanitize_file_name). I can imagine there being more than one unicode representation of á (as is the case with the Swedish characters åäö for example), or perhaps the filename you are uploading is encoded using ISO-8859-1, so try to isolate which is being used in your case and try uploading a with few differently encoded file names if possible. Also, try to isolate this to a server or client issue, i.e. upload the same file to different servers to find out if it behaves the same in different systems. This image, for example, uploads just fine at my clean WP install running on OS X/MAMP.

|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.