Nothing worse than user contributed image files with strange (non-english) characters in the file name right? Here’s what you can do about it in WordPress.

If you are working with WordPress Sites in non-english languages, like for instance Swedish, like I am, sometimes there can be a world if pain when moving sites between hosts if the file names include non-standard charachters such as åÅ, äÄ, öÖ. The images appear as broken, becuase something with the file name encoding happens along the way. Here is a function to put in your themes functions.php that will help sanitize file names of uploaded files.

add_filter(‘sanitize_file_name’, ‘sa_sanitize_chars’, 10);

function sa_sanitize_chars ($filename) {
return remove_accents( $filename );
}

Source: http://clubmate.fi/remove-weird-characters-like-o-and-a-from-file-names-in-wordpress-aka-sanitise-file-upload-image-names/

Don't be shellfish...Share on LinkedInShare on Google+Tweet about this on TwitterPin on PinterestShare on Facebook
  • Dan Svensson

    Hejsan! Fungerar detta tillsammans med Contact Form 7? Jag har problem på en sida där CF7 används. Om en fil med åäö laddas upp så blir det fel när den ska bifogas i mailet som CF7 genererar.

    Tack,
    Dan Svensson

  • leanderlindahl

    Hej Dan, jag tror att det borde fungera, men det finns bara ett sätt att ta reda på det – att testa! Återkom gärna med feedback, så att andra kan dra nytta av vad du kom fram till.