diff --git wp-admin/js/post-formats.js wp-admin/js/post-formats.js
index 69729ad..54e8a75 100644
|
|
|
1 | 1 | window.wp = window.wp || {}; |
2 | 2 | |
3 | 3 | (function($) { |
4 | | var container, mediaFrame, lastMimeType, mediaPreview, |
| 4 | var container, mediaFrame, lastMimeType, mediaPreview, insertMediaButton, |
5 | 5 | noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery'], |
6 | 6 | $container = $( '.post-formats-fields' ), |
7 | 7 | $screenIcon = $( '.icon32' ); |
… |
… |
window.wp = window.wp || {}; |
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
| 62 | // If gallery, force it to open to gallery state |
| 63 | if ( 'gallery' === format ) |
| 64 | insertMediaButton.addClass( 'gallery' ); |
| 65 | else |
| 66 | insertMediaButton.removeClass( 'gallery' ); |
| 67 | |
62 | 68 | postFormats.currentPostFormat = format; |
63 | 69 | } |
64 | 70 | |
65 | | $(function(){ |
| 71 | $(function() { |
| 72 | insertMediaButton = $( '#insert-media-button' ); |
66 | 73 | |
67 | 74 | $('.post-format-change a').click(function() { |
68 | 75 | $('.post-formats-fields, .post-format-change').slideUp(); |
diff --git wp-includes/js/media-editor.js wp-includes/js/media-editor.js
index 96a6f1c..3e2a651 100644
|
|
|
538 | 538 | add: function( id, options ) { |
539 | 539 | var workflow = this.get( id ); |
540 | 540 | |
541 | | if ( workflow ) |
542 | | return workflow; |
543 | | |
544 | 541 | workflow = workflows[ id ] = wp.media( _.defaults( options || {}, { |
545 | 542 | frame: 'post', |
546 | 543 | state: 'insert', |
… |
… |
|
692 | 689 | } |
693 | 690 | }, |
694 | 691 | |
695 | | open: function( id ) { |
| 692 | open: function( id, options ) { |
696 | 693 | var workflow, editor; |
697 | 694 | |
| 695 | options = options || {}; |
| 696 | |
698 | 697 | id = this.id( id ); |
699 | 698 | |
700 | 699 | // Save a bookmark of the caret position in IE. |
… |
… |
|
709 | 708 | |
710 | 709 | workflow = this.get( id ); |
711 | 710 | |
712 | | // Initialize the editor's workflow if we haven't yet. |
713 | | if ( ! workflow ) |
714 | | workflow = this.add( id ); |
| 711 | // Redo workflow if state has changed |
| 712 | if ( ! workflow || ( workflow.options && options.state !== workflow.options.state ) ) |
| 713 | workflow = this.add( id, options ); |
715 | 714 | |
716 | 715 | return workflow.open(); |
717 | 716 | }, |
… |
… |
|
719 | 718 | init: function() { |
720 | 719 | $(document.body).on( 'click', '.insert-media', function( event ) { |
721 | 720 | var $this = $(this), |
722 | | editor = $this.data('editor'); |
| 721 | editor = $this.data('editor'), |
| 722 | options = { |
| 723 | frame: 'post', |
| 724 | state: 'insert', |
| 725 | title: wp.media.view.l10n.addMedia, |
| 726 | multiple: true |
| 727 | }; |
723 | 728 | |
724 | 729 | event.preventDefault(); |
725 | 730 | |
… |
… |
|
730 | 735 | // See: http://core.trac.wordpress.org/ticket/22445 |
731 | 736 | $this.blur(); |
732 | 737 | |
733 | | wp.media.editor.open( editor ); |
| 738 | if ( $this.hasClass( 'gallery' ) ) { |
| 739 | options.state = 'gallery'; |
| 740 | options.title = wp.media.view.l10n.createGalleryTitle; |
| 741 | } |
| 742 | |
| 743 | wp.media.editor.open( editor, options ); |
734 | 744 | }); |
735 | 745 | } |
736 | 746 | }; |