[wp-trac] [WordPress Trac] #27698: Add hooks to the wpeditimage tinymce plugin and to the image details portion of the media modal
WordPress Trac
noreply at wordpress.org
Thu Apr 10 17:40:26 UTC 2014
#27698: Add hooks to the wpeditimage tinymce plugin and to the image details
portion of the media modal
-------------------------+-----------------------------------------
Reporter: gcorne | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses: javascript, administration
-------------------------+-----------------------------------------
Comment (by gcorne):
Moving this ticket to the 3.9 milestone, although it may be punted in
favor of #27706
In [attachment:27698-04.patch 27698-04.patch], I have revised both what is
used for the hooks and also several aspects of the image details modal
works in order to create an unfinished [attachment:image-edit-advanced.zip
plugin] that demonstrates how a developer could hook in and add additional
functionality. The plugin in its current form just adds a border to the
image in a rough fashion.
Some notes about the patch that may warrant discussion:
* Adds {{{wp.media.hooks}}} which is intended to be a global media event
bus. The idea is that it would make sense when in the context of media to
have an event bus that third-party code can listen for events on. I think
this is cleaner than using jQuery when in the context of media, and is a
starting point for adding more places for developers to hook in to media.
* Adds a {{{post-render}}} event to the {{{ImageDetails}}} view that
third-party code can leverage to add subviews. While incorporating this, I
discovered a drawback with the {{{Settings}}} view and its magic, which is
that the parent {{{Settings}}} view will still respond to events that
occur as a result of user actions in the subview. This is magnified
because the event bindings are quite generic. One way around this would be
to break up the various blocks of settings into separate subviews.
* I now fully understand the relationship between the {{{create}}} region
event and the {{{render}}} region event. There are places where she should
be using {{{create}}}, which simplifies the code a bit and more
importantly opens the door to 3rd-party developers being able to add
{{{render}}} events that add subviews or override the view.
* The patch also adds a performance improvement change to how the
PostImage model is initialized. If the user opens a modal referencing a
image that has already been fetched, it is probably safe to just reuse the
existing model instead of fetching again.
* Adds a bit more markup to the image details template to make it easier
to add a view to the image portion of advanced options.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27698#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list