[wp-trac] [WordPress Trac] #40427: Expose a JavaScript API to extend the Media Manager
WordPress Trac
noreply at wordpress.org
Wed Apr 19 20:44:21 UTC 2017
#40427: Expose a JavaScript API to extend the Media Manager
---------------------------+------------------------------
Reporter: jonathanbardo | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses: javascript
---------------------------+------------------------------
Comment (by westonruter):
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.
([https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L556-L567 ref])
2. Disable syncing of attachment changes back to server.
[https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L587-L594 ref]. See #40403.
3. Add CSS class to modal container element [https://github.com/xwp/wp-
core-media-widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-
admin/js/widgets/media-widgets.js#L596 ref]
4. Give keyboard focus on the first focusable element in the active state.
[https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L611-L615 ref]
5. Allow the text of the “Insert into Post” button from the embed toolbar
to be set by `options`. [https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L250 ref]
6. Allow the “Link Text” field to be suppressed entirely in embedding.
Refs [https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L255-L273 1], [https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L140-L149 2].
7. Allow the initial attachment display options to be set when opening the
modal and let them persist across attachment selections. Refs
[https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L25-L77 1], [https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L193 2], [https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L562 3].
8. Allow the “Insert into Post” button text to be overridden by
configuration in the main insert toolbar. [https://github.com/xwp/wp-core-
media-widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-
admin/js/widgets/media-widgets.js#L219 ref]
9. Allow embed frame to render embed previews properly when there is no
post context available. [https://github.com/xwp/wp-core-media-
widgets/blob/8fb6a010128fc61c6c9fbf7368b42fecd395d425/wp-admin/js/widgets
/media-widgets.js#L102-L138 ref]. See #40450.
Some of these already have tickets, while others should get their own
tickets.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40427#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list