WordPress.org

Make WordPress Core

Opened 2 weeks ago

Last modified 8 days ago

#40427 new enhancement

Expose a JavaScript API to extend the Media Manager

Reported by: jonathanbardo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Media Keywords:
Focuses: javascript Cc:

Description

After talking with @mikeschroder as Pressnomics about how hard it was to extend the media manager, I wanted to open the discussion here for ways we could improve that.

One way I made it work for the Stock Photo plugins at GoDaddy was to override core bindHandlers (see https://github.com/godaddy/wp-stock-photos/blob/master/assets/js/stock-photos.manifest.js#L13) and register my new view. One problem with that approach is that it makes it hard for anyone else to extend it for themselves.

I'm turning out to the community so we can discuss ways we could expose hooks that would let anyone extend any part of the media manager experience. This could pave the way for awesome new plugins.

Change History (4)

#1 @jonathanbardo
2 weeks ago

  • Summary changed from Expose an API to extend the Media Manager to Expose a JavaScript API to extend the Media Manager

#2 @westonruter
9 days ago

I'll comment here as well with some learnings from working with the media manager JS for the media widgets. We had to extend the media modal JS a few times to get it to behave the way we needed. I'll list out the reasons for extending here and perhaps they indicate areas where more configuration (options) are needed when invoking the media modal, or perhaps changes to the default behavior.

  1. Allow calls to wp.media() to pass in the desired Library instead of having a fixed set in that large if/else statement. (ref)
  2. Disable syncing of attachment changes back to server. ref. See #40403.
  3. Add CSS class to modal container element ref
  4. Give keyboard focus on the first focusable element in the active state. ref
  5. Allow the text of the “Insert into Post” button from the embed toolbar to be set by options. ref
  6. Allow the “Link Text” field to be suppressed entirely in embedding. Refs 1, 2.
  7. Allow the initial attachment display options to be set when opening the modal and let them persist across attachment selections. Refs 1, 2, 3.
  8. Allow the “Insert into Post” button text to be overridden by configuration in the main insert toolbar. ref
  9. Allow embed frame to render embed previews properly when there is no post context available. ref. See #40450.

Some of these already have tickets, while others should get their own tickets.

This ticket was mentioned in Slack in #core-media by joemcgill. View the logs.


8 days ago

This ticket was mentioned in Slack in #core-media by westonruter. View the logs.


8 days ago

Note: See TracTickets for help on using tickets.