I want my files being renamed automatically on upload to a random number that does not interfere with other random named files. I am new to PHP and do not want to change a code snippet every year to keep it compatible with current WordPress versions, if possible. Snippets are ok, I have WPCodebox, but they should work for a long time secure without changing. I only found posts that are at least 10 years old (e.g., https://stackoverflow.com/questions/11586284/rename-files-on-upload-in-wordpress-3-4-1) and I can not judge whether the code is still useful or safe as it is.
Does anyone know such a code snippet or a plugin for that job?
Context: I want to create a private area that is password protected. Since the media files can not be protected if accessed by their filenames (just with high-priced plugins) I want to make it very hard to be indexed by any crawlers. I hope that idea solves this problem, please tell me if I am wrong.
/attachment-sitemap.xml
then if the crawler / indexer can't see the attachment - it can't be indexed. You can only index the content you're given