How could I add button next to "edit image" button in "Attachment Details"

This is the location I would like to add button, Do you have any recommend?

enter image description here

  • Hmm, this doesn't look like an easy task to achieve with just a hook, although I could be wrong. I can point you towards the files you can investigate if it helps? If you go to wp-includes/media-template.php, there is code that generates the "edit image" button there. In wp-includes/media.php, it calls the media-template.php file to be used. Hope it helps as a starting point at least! Also just a gentle reminder not to edit these files, but to use them to formulate your own solution. Good luck! – RachieVee Aug 28 '15 at 16:40
  • you mean I have to do some kind of monkey patching?. Do you have any specific recommend. Thank you very much – KKND_BLACK Sep 1 '15 at 10:29
  • I'm not sure what you mean by monkey patching haha but I'm honestly not sure of the exact solution. I just know it doesn't appear it's as simple as using a hook to add a button, but I could be missing something - hence why I pointed you to those files. I also know the media library runs on Backbone so doing some research in that area may help as well. Good luck! – RachieVee Sep 2 '15 at 22:00
  • 1
    Perhaps if you describe what you intend the button to do, we could maybe help with alternative ways to do it? Or you could look at wordpress.org/plugins/yoimages. It adds a 'edit crop formats' button - possibly with javascript – anmari Jun 29 '18 at 1:12
  • Thanks, I want to add a button there and execute some code onClick without hacking at the core. – LumberHack Jul 4 '18 at 10:35

I would recommend that you begin by having a look at a question asked more recently here.

The best option would be to create a custom plugin so that the WP core doesn't get affected. Editing core files is never a good idea, plus you would lose any changes when updating WP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.