我检查下面的答案,在上传过程中重命名文件,并尝试将其更改为类似postid\\u originalfilename的内容。jpg但失败。有什么帮助吗?
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);
https://stackoverflow.com/questions/11586284/rename-files-on-upload-in-wordpress-3-4-1