Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#50185 closed enhancement (fixed)

Expose the MediaFrame.MediaFrame frame via a ready trigger

Reported by: soulseekah's profile soulseekah Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch has-dev-note
Focuses: javascript Cc:

Description

It is currently impossible to grab the initial "manage" View (Frame) (which contains all the other Subviews).

Use case: I'd like to make modifications to the modal, add some event handlers, which I'm unable to do reliably I have nothing to do .on() with.

I have to wait for some of the components to appear. That means looping or other dirty hacks. I propose to trigger a DOM even on the initial container.

With the attached patch I can do something like:

jQuery( document ).on( 'wp-media-grid-ready', '##wp-media-grid', function( e, frame ) {
    frame.on( 'edit:attachment', function() {
        // Code that runs when the modal is being opened.
    }
} );

Related #35205

Attachments (1)

50185.diff (632 bytes) - added by soulseekah 4 years ago.

Download all attachments as: .zip

Change History (5)

@soulseekah
4 years ago

#1 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.5

#2 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 47807:

Media: Expose media grid frame via wp-media-grid-ready trigger for easier customization.

Props soulseekah.
Fixes #50185.

#3 @garrett-eclipse
4 years ago

  • Keywords needs-dev-note added

#4 @desrosj
4 years ago

  • Keywords has-dev-note added; needs-dev-note removed

This received a call out in the Miscellaneous Developer Changes in 5.5 dev note: https://make.wordpress.org/core/2020/07/29/miscellaneous-developer-focused-changes-in-wordpress-5-5/.

Note: See TracTickets for help on using tickets.