WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Uploaded image with accents in name, image don't show in Safari 6

[Resolved] Uploaded image with accents in name, image don't show in Safari 6

Viewing 4 replies - 1 through 4 (of 4 total)
  • codingpet
    Member

    @codingpet

    http://www.soulcie.fr/wp-content/uploads/2012/08/120820_présidence-ump-bousier-scarabées.jpg

    http://www.soulcie.fr/wp-content/uploads/2012/08/120820_présidence-ump-bousier-scarabées.jpg

    I can’t see any differences for the two URL but they are different if you just copy it. The first one is correct while the second is broken. The é in the two URL are different if you view the two URL in notepad.

    It will be good to not use german characters in image name. Further problems will happen if there are special characters in image name(for example, some hosting will encode these characters if you upload via FTP but will not encode it when uploading in wordpress. This will cause different image URL in hosting and wordpress database when you transfer/restore site).

    bitox
    Member

    @bitox

    Okay, so your advice is not to use special characters in the file names. Why wouldn’t wordpress media uploader rename the special characters? BTW, they’re french 🙂
    Thanks,

    memovera
    Member

    @memovera

    This wp function works for me: remove_accents. Hope it helps 😀
    Example:

    WordPress: Remove Special Characters From Uploaded Files

    bitox
    Member

    @bitox

    Thanks for the hint!
    It worked for me with the following code in functions.php

    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);

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Uploaded image with accents in name, image don't show in Safari 6’ is closed to new replies.