What language are those chars from?
French. Examples of french characters: éèêâîçàôùû.
Small correction: the resulting name did not have any spacing (unlike what I wrote above, or what the WordPress comment system did to what I wrote), so that was not an issue. Just the special characters.
-
This reply was modified 4 years ago by
Samuel.
– I’m on a Mac, OSX 10.11.6.
– In english.
– I use Firefox 50.1.
I made a new test, using an image called test élève garçon.png
, with Chrome (version 55.0) this time, and I got the same result: spacing were correctly replaced with “-“, but special characters remained in the file name: test-élève-garçon.png
.
Then I also switched my Mac computer to french, did that last test again in Firefox and Chrome, and it was the same result.
I was facing the same issue. My guess is if the file is uploaded from Mac OS, the special characters are encoded in some proprietary Mac encoding – in my client’s case it was probably the Macintosh Central European encoding. In such case the current plugin’s replacement method will not work properly.
I found the following solution.
Change:
$friendly_filename = preg_replace( array_keys( $chars_table ), array_values( $chars_table ), $filename );
return strtolower( $friendly_filename );
To:
$friendly_filename = preg_replace( array_keys( $chars_table ), array_values( $chars_table ), $filename );
$transliterate_filename = transliterator_transliterate(‘Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove’, $friendly_filename);
return strtolower( $transliterate_filename );
@webvitaly In case you’d like to list me as a contributor, I’d be grateful:)