is there a way to rename files during the upload progress within the Wordpress 3.0 backend? I would like to have a consistent naming of files, especially for im
http://wpapi.com/change-image-name-to-wordpress-post-slug-during-upload/
BTW:
Add filter to sanitize_file_name is totally wrong, as sanitize_file_name() function is a helper function to format string, it may be used elsewhere like plugins or themes.
function wp_modify_uploaded_file_names($file) {
$info = pathinfo($file['name']);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = basename($file['name'], $ext);
$file['name'] = uniqid() . $ext; // uniqid method
// $file['name'] = md5($name) . $ext; // md5 method
// $file['name'] = base64_encode($name) . $ext; // base64 method
return $file;
}
add_filter('wp_handle_upload_prefilter', 'wp_modify_uploaded_file_names', 1, 1);