Archives

Remove Special Characters From Uploaded Files

This is probably more practical if you deal with a lot of special characters, perhaps in foreign languages. But if you want to make sure particular characters are removed from file name when uploaded, you can. As always, WordPress makes this easy.

add_filter( 'sanitize_file_name_chars', 'add_chars_to_filter', 10, 2 );
function add_chars_to_filter ( $special_chars, $filename_raw ) {
	$special_chars[] = 'e';
	return $special_chars;
}

This particular is example is useless as-is, unless you have something against our favorite vowel ‘e.’