[wp-trac] [WordPress Trac] #65086: Add action hooks to media modal attachment details templates for field extensibility

WordPress Trac noreply at wordpress.org
Tue Apr 28 09:56:20 UTC 2026


#65086: Add action hooks to media modal attachment details templates for field
extensibility
-------------------------+------------------------------
 Reporter:  kaavyaiyer   |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Media        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by darshitrajyaguru97):

 This is a great initiative and clearly needed, especially with AI-powered
 features like alt text generation.

 One important consideration: since the attachment details UI is rendered
 via Backbone templates (`media-template.php`), traditional PHP action
 hooks (`do_action`) won’t be effective inside `<script type="text/html">`
 blocks.

 A more robust approach could be introducing JavaScript-based extensibility
 points using `wp.hooks`, for example:

 {{{
 wp.hooks.doAction(
   'media_attachment_field_after',
   'alt',
   view,
   model
 );
 }}}

 Additionally, field-specific hooks (e.g.,
 `media_attachment_field_after_alt`,
 `media_attachment_field_before_caption`) would provide more granular
 control and avoid reliance on DOM querying.

 As an alternative or fallback, Core could introduce dedicated placeholder
 containers within templates (e.g., `.media-field-hook-alt`) to allow safe
 UI injection without fragile DOM manipulation.

 This approach would:

 * Avoid performance overhead from runtime DOM mutations
 * Provide a stable API for plugins
 * Align well with AI-driven enhancements like alt text, caption, and title
 generation

 Starting with the media modal makes sense, and this pattern could later
 extend to other admin UI areas where contextual field-level extensibility
 is needed.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65086#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list