Opened 11 years ago
Closed 11 years ago
#27698 closed enhancement (fixed)
Add hooks to the wpeditimage tinymce plugin and to the image details portion of the media modal
Reported by: | gcorne | Owned by: | gcorne |
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Editor | Keywords: | has-patch commit |
Focuses: | javascript, administration | Cc: |
Description
In order to extend the new image details media modal, there are some hooks that are needed both inside the wpeditimage
tinymce plugin and also in media-template.php
. This will allow us to bring back the border and padding in a plugin if needed and also allow plugin authors an opportunity to incorporate custom functionality.
Attachments (5)
Change History (15)
This ticket was mentioned in IRC in #wordpress-dev by gcorne. View the logs.
11 years ago
This ticket was mentioned in IRC in #wordpress-dev by gcorne. View the logs.
11 years ago
#4
@
11 years ago
Moving this ticket to the 3.9 milestone, although it may be punted in favor of #27706
In 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 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 theImageDetails
view that third-party code can leverage to add subviews. While incorporating this, I discovered a drawback with theSettings
view and its magic, which is that the parentSettings
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 therender
region event. There are places where she should be usingcreate
, which simplifies the code a bit and more importantly opens the door to 3rd-party developers being able to addrender
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.
Patch looks good. Wondering if it would be better/easier to trigger custom jQuery events instead of TinyMCE events, and pass the editor instance. Something like:
Then that can be used without needing to make a TinyMCE plugin.