Using custom php to connect to database blocks wp from accessing galery pictures

The solution to this was dumb but it works. I just had to refresh the post article page once and I could access the media library again.

I guess the script would take preference over the media gallery? And then when I refreshed the page it would take preference again and could connect. I’m just guessing here, but if anybody else has this issue this is the simple fix.