Changeset 22568
- Timestamp:
- 11/14/2012 09:06:10 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r22541 r22568 384 384 */ 385 385 function media_buttons($editor_id = 'content') { 386 wp_enqueue_media(); 386 wp_enqueue_media( array( 387 'post' => get_post() 388 ) ); 387 389 388 390 $context = apply_filters('media_buttons_context', __('Upload/Insert %s')); -
trunk/wp-admin/js/media-upload.js
r22567 r22568 213 213 214 214 return { 215 attachments: function( shortcode, parent ) { 215 defaults: { 216 order: 'ASC', 217 orderby: 'post__in', 218 id: wp.media.view.settings.postId, 219 itemtag: 'dl', 220 icontag: 'dt', 221 captiontag: 'dd', 222 columns: 3, 223 size: 'thumbnail' 224 }, 225 226 attachments: function( shortcode ) { 216 227 var shortcodeString = shortcode.string(), 217 228 result = galleries[ shortcodeString ], … … 241 252 242 253 if ( ! args.post__in ) 243 args.parent = attrs.id || parent;254 args.parent = attrs.id; 244 255 245 256 // Collect the attributes that were not included in `args`. … … 284 295 285 296 return shortcode; 297 }, 298 299 edit: function( content ) { 300 var shortcode = wp.shortcode.next( 'gallery', content ), 301 defaultPostId = wp.media.gallery.defaults.postId, 302 attachments, selection; 303 304 // Bail if we didn't match the shortcode or all of the content. 305 if ( ! shortcode || shortcode.content !== content ) 306 return; 307 308 // Ignore the rest of the match object. 309 shortcode = shortcode.shortcode; 310 311 if ( _.isUndefined( shortcode.get('id') ) && ! _.isUndefined( defaultPostId ) ) 312 shortcode.set( 'id', defaultPostId ); 313 314 attachments = wp.media.gallery.attachments( shortcode ); 315 316 selection = new wp.media.model.Selection( attachments.models, { 317 props: attachments.props.toJSON(), 318 multiple: true 319 }); 320 321 selection.gallery = attachments.gallery; 322 323 return wp.media({ 324 frame: 'post', 325 state: 'gallery-edit', 326 title: wp.media.view.l10n.editGalleryTitle, 327 editing: true, 328 multiple: true, 329 selection: selection 330 }); 286 331 } 287 332 }; -
trunk/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin_src.js
r20519 r22568 11 11 // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'); 12 12 ed.addCommand('WP_Gallery', function() { 13 var el = ed.selection.getNode(), post_id, vp = tinymce.DOM.getViewPort(), 14 H = vp.h - 80, W = ( 640 < vp.w ) ? 640 : vp.w; 13 var el = ed.selection.getNode(), 14 gallery = wp.media.gallery, 15 frame; 15 16 16 if ( el.nodeName != 'IMG' ) return; 17 if ( ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 ) return; 17 // Check if the `wp.media.gallery` API exists. 18 if ( typeof wp === 'undefined' || ! wp.media || ! wp.media.gallery ) 19 return; 18 20 19 post_id = tinymce.DOM.get('post_ID').value; 20 tb_show('', tinymce.documentBaseURL + 'media-upload.php?post_id='+post_id+'&tab=gallery&TB_iframe=true&width='+W+'&height='+H); 21 // Make sure we've selected a gallery node. 22 if ( el.nodeName != 'IMG' || ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 ) 23 return; 21 24 22 tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' ); 25 frame = gallery.edit( '[' + ed.dom.getAttrib( el, 'title' ) + ']' ); 26 27 frame.get('gallery-edit').on( 'update', function( selection ) { 28 var shortcode = gallery.shortcode( selection ).string().slice( 1, -1 ); 29 ed.dom.setAttrib( el, 'title', shortcode ); 30 }); 23 31 }); 24 32 -
trunk/wp-includes/media.php
r22557 r22568 1301 1301 * @since 3.5.0 1302 1302 */ 1303 function wp_enqueue_media() { 1303 function wp_enqueue_media( $args = array() ) { 1304 $defaults = array( 1305 'post' => null, 1306 ); 1307 $args = wp_parse_args( $args, $defaults ); 1308 1304 1309 // We're going to pass the old thickbox media tabs to `media_upload_tabs` 1305 1310 // to ensure plugins will work. We will then unset those tabs. … … 1321 1326 ), admin_url('media-upload.php') ), 1322 1327 ); 1328 1329 if ( isset( $args['post'] ) ) 1330 $settings['postId'] = get_post( $args['post'] )->ID; 1323 1331 1324 1332 wp_localize_script( 'media-views', '_wpMediaViewsL10n', array(
Note: See TracChangeset
for help on using the changeset viewer.