When I upload an image to WordPress with the name:
- Image20_O9KA M 21.jpg
Wordpress will change the permalink to: - Image20_09KA-M-21.jpg
I would need the format:
- Image_09KA_M_21.jpg
How can I get that format automatically when uploading new images?
When I upload an image to WordPress with the name:
I would need the format:
How can I get that format automatically when uploading new images?
2
Answers
You can try below filter.
Not tested.
Same method as @Akhtarujjaman Shuvo but replacing the
$filename
whitespaces and hyphens with underscores before returning through thesanitize_file_name
filter…In theory (not tested)…
Uploaded filename:
Image20_O9KA M 21.jpg
Filename result:
Image20_O9KA_M_21.jpg