If you suddenly find out that you changed nothing to your project but your media library stopped working, there is a possibility that your website was hacked or code was injected to it.
Start by checking the wp-config.php and locate any unusual code on the top or at the bottom of your file.
If you find something like the one in the photos, means that there was code injected to your website causing all the malfunction.
Remove it and then start a full antivirus check from your panel.
The next thing would be to change your login password.