-
-
Save webdev1001/ef4269e2418d94a496c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sanitize File name during upload | |
* http://stackoverflow.com/questions/3259696/rename-files-during-upload-within-wordpress-backend | |
*/ | |
function make_filename_hash($filename) { | |
$info = pathinfo($filename); | |
$ext = empty($info['extension']) ? '' : '.' . $info['extension']; | |
$name = basename($filename, $ext); | |
return md5($name) . $ext; | |
} | |
add_filter('sanitize_file_name', 'make_filename_hash', 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment