Hi
I had the same problem as you. Putting the code in the plugins.php file located in your theme doesn’t work.
That said, I came across another topic:
https://ww.wp.xz.cn/support/topic/enable-access-for-editors-in-addition-to-administrators/
As I’m not a wordpress developer, I didn’t understand much… the person talks about “MU Plugins” and I saw that there’s a folder named “mu-plugins” in “wp-content”… I created a .php file named media-file-renamer.php and pasted the code… and voilà 🙂
I hope your answer helps you or the next person. I created an account just for that.