[wp-trac] [WordPress Trac] #23096: Provide callback before setting state of the editor media manager
WordPress Trac
noreply at wordpress.org
Fri Sep 12 04:00:24 UTC 2014
#23096: Provide callback before setting state of the editor media manager
-------------------------+------------------
Reporter: griffinjt | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.1
Component: Media | Version: 3.5
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------+------------------
Changes (by wonderboymusic):
* keywords: has-patch dev-feedback => has-patch
* milestone: Awaiting Review => 4.1
Comment:
If you want to override the click handler, you should remove it and add
your own - since the current `click` handler is delegated, and isn't
namespaced, this is messy. My patch [attachment:23096.2.diff] namespaces
the click handler: `click.add_media_button`
With it, you can just do:
{{{
$( document.body )
.off( 'click.add_media_button' )
.on( 'click.add_media_button', '.insert-media', function ( event ) {
var elem = $( event.currentTarget ),
editor = elem.data('editor'),
options = {
frame: '{WHATEVER_YOU_WANT}',
state: '{WHATEVER_YOU_WANT}',
title: '{WHATEVER_YOU_WANT}',
};
event.preventDefault();
elem.blur();
wp.media.editor.open( editor, options );
} )
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/23096#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list