The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Uploaded image with accents in name, image don't show in Safari 6 (5 posts)

  1. bitox
    Posted 4 years ago #

    You can see the page http://www.soulcie.fr/portfolio/a-qui-ira-lump/ (Gridlocked theme). With Safari, the image don't show, because he can't get the URL http://www.soulcie.fr/wp-content/uploads/2012/08/120820_pre%CC%81sidence-ump-bousier-scarabe%CC%81es.jpg
    Can you help me determine if it is a WP related problem (should remove special characters at upload), a Gridlocked theme problem… or Safari is lame ?
    Thank you

  2. codingpet
    Posted 4 years ago #



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

  3. bitox
    Posted 3 years ago #

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

  4. memovera
    Posted 3 years ago #

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

  5. bitox
    Posted 3 years ago #

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


Topic Closed

This topic has been closed to new replies.

About this Topic