Excellent software and practical tutorials
Select the theme editor in the appearance options of the WordPress background, select the init-functions.php template file in the theme functions directory and insert the following code. It's simple and convenient!
Rename pictures by time
When uploading a file, it will be renamed in the format of "year-month-day-hour-minute-second + thousandths of milliseconds integer", such as "20200307031021765.jpg"
[cc lang="php"]
// Rename the uploaded file
function git_upload_filter($file) {
$time = date("YmdHis");
$file['name'] = $time . "" . mt_rand(1, 100) . "." . pathinfo($file['name'], PATHINFO_EXTENSION);
return $file;
}
add_filter('wp_handle_upload_prefilter', 'git_upload_filter');
After saving the file, you can automatically rename it when you upload it in Media.