[wp-trac] [WordPress Trac] #35205: Add additional hooks to the 'attachment-info' template to customise output

WordPress Trac noreply at wordpress.org
Tue Dec 22 23:05:33 UTC 2015


#35205: Add additional hooks to the 'attachment-info' template to customise output
------------------------------+-----------------------------
 Reporter:  simonrcodrington  |      Owner:
     Type:  feature request   |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Administration    |    Version:
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 Hey guys,

 I've been working on several sites for clients and one thing that keeps
 coming up is the need to customise the 'attachment info' screen when
 viewing media items in the fancy media modal.

 [[Image(http://drive.google.com/uc?export=view&id=0BxFkQxv15MkfUWJNUnBMb3gxa00)]]

 You can see that the screen shows the attachment info at the top, followed
 additional info below (for example the file name, file type, uploaded date
 at the top followed by editable fields below such as title, caption etc)

 All of this is defined in `/wp-includes/media-template.php` and pretty
 much hard coded, looking for the upload type and then displaying fields.

 There is already an
 [https://codex.wordpress.org/Plugin_API/Filter_Reference/attachment_fields_to_edit
 'attachment_fields_to_edit'] action but what that does is allow you at add
 fields to the ''bottom of the existing fields'' as such.

 [[Image(http://drive.google.com/uc?export=view&id=0BxFkQxv15MkfSUVhby1pQm9Mc3M)]]

 I would propose a few new hooks be created inside `media-template.php`
 starting from line 338. This is the start of the `attachment-info` panel
 and it's here a few actions would be helpful.

 For example a client wanted to see all of their different image sizes in
 the attachment screen so they could easily copy them. Currently this can
 only be done by editing core directly (which is a terrible idea).

 [[Image(http://drive.google.com/uc?id=0BxFkQxv15Mkfd2dwdXRkMm93SHM)]]

 Since the media modal is built dynamically with Ajax if we add hooks here
 developers will be able to access the media object (which contains the
 URL, title, id and other info). So the flexibility will be really neat.

 I'm more than happy to look into this but I'd be really keep to get
 feedback from you guys just in case I am missing something critical
 (because I don't know why there is a lack of hooks here for development)

 I'm thinking of adding just basic hooks like

 ```do_action('media-attachment-info-start')```


 Cheers

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35205>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list