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. git-svn-id: https://develop.svn.wordpress.org/trunk@29779 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0fe756a461
commit
d19b2ded94
|
@ -437,8 +437,9 @@ window.wp = window.wp || {};
|
||||||
*
|
*
|
||||||
* @param view {object} being refreshed
|
* @param view {object} being refreshed
|
||||||
* @param text {string} textual representation of the view
|
* @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 ),
|
var encodedText = window.encodeURIComponent( text ),
|
||||||
viewOptions,
|
viewOptions,
|
||||||
result, instance;
|
result, instance;
|
||||||
|
@ -454,7 +455,7 @@ window.wp = window.wp || {};
|
||||||
instances[ encodedText ] = instance;
|
instances[ encodedText ] = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.render();
|
instance.render( force );
|
||||||
},
|
},
|
||||||
|
|
||||||
getInstance: function( encodedText ) {
|
getInstance: function( encodedText ) {
|
||||||
|
@ -525,7 +526,9 @@ window.wp = window.wp || {};
|
||||||
|
|
||||||
_.each( attachments, function( attachment ) {
|
_.each( attachments, function( attachment ) {
|
||||||
if ( attachment.sizes ) {
|
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;
|
attachment.thumbnail = attachment.sizes.thumbnail;
|
||||||
} else if ( attachment.sizes.full ) {
|
} else if ( attachment.sizes.full ) {
|
||||||
attachment.thumbnail = attachment.sizes.full;
|
attachment.thumbnail = attachment.sizes.full;
|
||||||
|
@ -552,9 +555,10 @@ window.wp = window.wp || {};
|
||||||
frame = gallery.edit( data );
|
frame = gallery.edit( data );
|
||||||
|
|
||||||
frame.state('gallery-edit').on( 'update', function( selection ) {
|
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 ) );
|
$( 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() {
|
frame.on( 'close', function() {
|
||||||
|
|
|
@ -734,6 +734,31 @@ function wp_print_media_templates() {
|
||||||
<span><?php _e( 'Random Order' ); ?></span>
|
<span><?php _e( 'Random Order' ); ?></span>
|
||||||
<input type="checkbox" data-setting="_orderbyRandom" />
|
<input type="checkbox" data-setting="_orderbyRandom" />
|
||||||
</label>
|
</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>
|
||||||
|
|
||||||
<script type="text/html" id="tmpl-playlist-settings">
|
<script type="text/html" id="tmpl-playlist-settings">
|
||||||
|
|
Loading…
Reference in New Issue