How to fix broken media library?

Usually, the determination of the culprit involves one or more of the following:

1) Try one of the Twenty themes.

2) Disable all plugins (quickly via FTP renaming the plugins folder).

If a theme, contact the theme support.

If a plugin, add plugins one at a time (create a new plugins folder,them move plugin folders into there one-two at a time, until the problem reoccurs). When you determine the at-fault plugin, contact the plugin’s support forum.

This assumes that you haven’t moved domains lately (moving domains requires search/replace of the old/new domains in the database to update things).