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.

Built from https://develop.svn.wordpress.org/trunk@29779


git-svn-id: http://core.svn.wordpress.org/trunk@29551 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-09-29 03:45:16 +00:00
parent b646f9df6a
commit 75d347b259
3 changed files with 35 additions and 6 deletions

View File

@ -437,8 +437,9 @@ window.wp = window.wp || {};
*
* @param view {object} being refreshed
* @param text {string} textual representation of the view
* @param force {Boolean} whether to force rendering
*/
refreshView: function( view, text ) {
refreshView: function( view, text, force ) {
var encodedText = window.encodeURIComponent( text ),
viewOptions,
result, instance;
@ -454,7 +455,7 @@ window.wp = window.wp || {};
instances[ encodedText ] = instance;
}
instance.render();
instance.render( force );
},
getInstance: function( encodedText ) {
@ -525,7 +526,9 @@ window.wp = window.wp || {};
_.each( attachments, function( attachment ) {
if ( attachment.sizes ) {
if ( attachment.sizes.thumbnail ) {
if ( attrs.size && attachment.sizes[ attrs.size ] ) {
attachment.thumbnail = attachment.sizes[ attrs.size ];
} else if ( attachment.sizes.thumbnail ) {
attachment.thumbnail = attachment.sizes.thumbnail;
} else if ( attachment.sizes.full ) {
attachment.thumbnail = attachment.sizes.full;
@ -552,9 +555,10 @@ window.wp = window.wp || {};
frame = gallery.edit( data );
frame.state('gallery-edit').on( 'update', function( selection ) {
var shortcode = gallery.shortcode( selection ).string();
var shortcode = gallery.shortcode( selection ).string(), force;
$( node ).attr( 'data-wpview-text', window.encodeURIComponent( shortcode ) );
wp.mce.views.refreshView( self, shortcode );
force = ( data !== shortcode );
wp.mce.views.refreshView( self, shortcode, force );
});
frame.on( 'close', function() {

File diff suppressed because one or more lines are too long

View File

@ -734,6 +734,31 @@ function wp_print_media_templates() {
<span><?php _e( 'Random Order' ); ?></span>
<input type="checkbox" data-setting="_orderbyRandom" />
</label>
<label class="setting size">
<span><?php _e( 'Size' ); ?></span>
<select class="size" name="size"
data-setting="size"
<# if ( data.userSettings ) { #>
data-user-setting="imgsize"
<# } #>
>
<?php
// This filter is documented in wp-admin/includes/media.php
$size_names = apply_filters( 'image_size_names_choose', array(
'thumbnail' => __( 'Thumbnail' ),
'medium' => __( 'Medium' ),
'large' => __( 'Large' ),
'full' => __( 'Full Size' ),
) );
foreach ( $size_names as $size => $label ) : ?>
<option value="<?php echo esc_attr( $size ); ?>">
<?php echo esc_html( $label ); ?>
</option>
<?php endforeach; ?>
</select>
</label>
</script>
<script type="text/html" id="tmpl-playlist-settings">