#32899 closed enhancement (worksforme)
Ability to extend Attachment Display Settings section
Reported by: | paulschreiber | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.2 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
It would be very helpful if WordPress let you easily extend the Attachment Display Settings section.
Currently, if you extend wp.media.view.Attachment.Details
, your render()
call gets access to this.$el
, something like
<div tabindex="0" data-id="75099" class="attachment-details save-ready"> ...
However, the DOM doesn't yet contain the attachment settings, i.e.
<div class="attachment-display-settings"> <h3>Attachment Display Settings</h3> ...
I had to use a crappy workaround like this:
setTimeout(function() { jQuery('.attachment-display-settings').append( wp.media.template('my-attachment-display-settings')({}) ); }, 200);
It would be very helpful if there was an easy way to extend the display settings section. One such way could be to fire an event after the render completes.
Change History (6)
#2
in reply to:
↑ 1
@
9 years ago
- Keywords reporter-feedback added
@paulschreiber Have you tried using 'attachment_fields_to_edit'
as suggested?
#3
@
9 years ago
Yes, I eventually used attachment_fields_to_edit
. It worked. However, that adds metadata to the database that persists with the image. I wanted something on the view layer only.
#4
@
9 years ago
- Keywords close reporter-feedback removed
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
If saving that metadata to the database is not desired, one could probably hook into the appropriate save_
action to unset the metadata.
have you tried
'attachment_fields_to_edit'
?