Make WordPress Core

Changeset 29779


Ignore:
Timestamp:
09/29/2014 03:44:25 AM (10 years ago)
Author:
wonderboymusic
Message:

Add size to the UI for Gallery Settings in the media modal. Ensure that the TinyMCE view is refreshed when size changes.

Props richardmtl, noplanman, wonderboymusic.
Fixes #18143.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/mce-view.js

    r29649 r29779  
    438438         * @param view {object} being refreshed
    439439         * @param text {string} textual representation of the view
     440         * @param force {Boolean} whether to force rendering
    440441         */
    441         refreshView: function( view, text ) {
     442        refreshView: function( view, text, force ) {
    442443            var encodedText = window.encodeURIComponent( text ),
    443444                viewOptions,
     
    455456            }
    456457
    457             instance.render();
     458            instance.render( force );
    458459        },
    459460
     
    526527                    _.each( attachments, function( attachment ) {
    527528                        if ( attachment.sizes ) {
    528                             if ( attachment.sizes.thumbnail ) {
     529                            if ( attrs.size && attachment.sizes[ attrs.size ] ) {
     530                                attachment.thumbnail = attachment.sizes[ attrs.size ];
     531                            } else if ( attachment.sizes.thumbnail ) {
    529532                                attachment.thumbnail = attachment.sizes.thumbnail;
    530533                            } else if ( attachment.sizes.full ) {
     
    553556
    554557            frame.state('gallery-edit').on( 'update', function( selection ) {
    555                 var shortcode = gallery.shortcode( selection ).string();
     558                var shortcode = gallery.shortcode( selection ).string(), force;
    556559                $( node ).attr( 'data-wpview-text', window.encodeURIComponent( shortcode ) );
    557                 wp.mce.views.refreshView( self, shortcode );
     560                force = ( data !== shortcode );
     561                wp.mce.views.refreshView( self, shortcode, force );
    558562            });
    559563
  • trunk/src/wp-includes/media-template.php

    r29764 r29779  
    734734            <span><?php _e( 'Random Order' ); ?></span>
    735735            <input type="checkbox" data-setting="_orderbyRandom" />
     736        </label>
     737
     738        <label class="setting size">
     739            <span><?php _e( 'Size' ); ?></span>
     740            <select class="size" name="size"
     741                data-setting="size"
     742                <# if ( data.userSettings ) { #>
     743                    data-user-setting="imgsize"
     744                <# } #>
     745                >
     746                <?php
     747                // This filter is documented in wp-admin/includes/media.php
     748                $size_names = apply_filters( 'image_size_names_choose', array(
     749                    'thumbnail' => __( 'Thumbnail' ),
     750                    'medium'    => __( 'Medium' ),
     751                    'large'     => __( 'Large' ),
     752                    'full'      => __( 'Full Size' ),
     753                ) );
     754
     755                foreach ( $size_names as $size => $label ) : ?>
     756                    <option value="<?php echo esc_attr( $size ); ?>">
     757                        <?php echo esc_html( $label ); ?>
     758                    </option>
     759                <?php endforeach; ?>
     760            </select>
    736761        </label>
    737762    </script>
Note: See TracChangeset for help on using the changeset viewer.