wordpress - Remove Special Characters From Uploaded Files -


i facing issues regarding filenames accented , found function sanitize filenames, not sure of if affect filenames in database or rename files?

here code:

add_filter('sanitize_file_name', 'sa_sanitize_spanish_chars', 10); function sa_sanitize_spanish_chars ($filename) { return remove_accents( $filename ); } 

try below code in function file.

function sa_sanitize_spanish_chars($filename) { $ext = end(explode('.',$filename)); $sanitized = preg_replace('/[^a-za-z0-9-_.]/','', substr($filename, 0, -(strlen($ext)+1))); $sanitized = str_replace('.','-', $sanitized); return strtolower($sanitized.'.'.$ext); }  add_filter('sanitize_file_name', 'sa_sanitize_spanish_chars', 10); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -