Yup. It’s working now.
Is there any way to put this code on all the attachment pages? It would be quite cumbersome to put the button manually in every page.
Also, can I change the look of the button and align it somewhere else along with a few other buttons?