Filter and Hooks, Programming, WordPress

Remove special character while uploading Media

The media having special characters in its name,  may not be visible in the front-end, therefore, we should remove the special character while  uploading media in the WordPress dashboard.   wp_handle_upload_prefilter, is admin filter that is called by the wp_handle_upload function, which helps to alter the filename before the file is moved to its destined location. The sole parameter $file, represent a single element of the $_FILES array.

Adding the aforementioned filter in the function.php, removes the special character from the name of the media prior to uploading it in WordPress dashboard.

Hits: 18

Standard