In current version of WordPress it is quite easy to expand the attachments fields using attachment_fields_to_edit
filter, but in latest WordPress 3.5 RC2 it’s not working. We can expand it using custom meta fields, but using this requires editing each attachment in Media tb. I was wondering if it is possible to expand fields in Attachment details in modal box with Media Library http://i.imgur.com/GIsJj.png (sorry for a link but I cannot add image, not enough reputation ;))
Thank you for any help.
You can add inputs and fields to attachments by hooking into
attachment_fields_to_edit
. This will add fields to both the modal as well as the attachment editor. The catch I found is that WordPress (if anyone has experienced differently PLMK) doesn’t save the extra fields data so you have to hook into a couple other items.I have added a code sample to give you add idea of what you could do.
You should still be able to use attachment_fields_to_edit, however those fields are also added to the modal window now. You can direct a field to only show up in the modal or only show up on the edit page by using the “show_in_edit” or “show_in_modal” parameters. Both are boolean and both default to true. Take a look at this trac ticket explaining the behavior: http://core.trac.wordpress.org/ticket/22759#comment:1
You should be aware that they seem to now be prefixed with “compat-field-” in the class names.