Media: Add size dropdown to attachment display settings in the media modal. fixes #22206, see #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-09 06:15:25 +00:00
parent 44314b715c
commit 76b23b3d48
2 changed files with 33 additions and 3 deletions

View File

@ -948,11 +948,11 @@
attachmentSettingsSidebar: function( options ) {
var state = this.state(),
display = state.get('details'),
single = state.get('selection').single().cid;
single = state.get('selection').single();
this.settingsSidebar({ silent: true });
display[ single ] = display[ single ] || new Backbone.Model({
display[ single.cid ] = display[ single.cid ] || new Backbone.Model({
align: getUserSetting( 'align', 'none' ),
size: getUserSetting( 'imgsize', 'medium' ),
link: getUserSetting( 'urlbutton', 'post' )
@ -961,7 +961,8 @@
this.sidebar.view().add({
display: new media.view.Settings.AttachmentDisplay({
controller: this,
model: display[ single ],
model: display[ single.cid ],
sizes: single.get('sizes'),
priority: 100,
userSettings: state.get('displayUserSettings')
}).render()

View File

@ -1471,6 +1471,35 @@ function wp_print_media_templates( $attachment ) {
<?php esc_attr_e('None'); ?>
</button>
</div>
<# if ( ! _.isUndefined( sizes ) ) { #>
<h4><?php _e('Size'); ?></h4>
<select class="size" name="size"
data-setting="size"
<# if ( userSettings ) { #>
data-user-setting="imgsize"
<# } #>>
<?php
$sizes = apply_filters( 'image_size_names_choose', array(
'thumbnail' => __('Thumbnail'),
'medium' => __('Medium'),
'large' => __('Large'),
) );
foreach ( $sizes as $value => $name ) : ?>
<# if ( ! _.isUndefined( sizes['<?php echo esc_js( $value ); ?>'] ) ) { #>
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'medium' ); ?>>
<?php echo esc_html( $name ); ?>
</option>
<# } #>>
<?php endforeach; ?>
<option value="full">
<?php echo esc_html_e( 'Full Size' ); ?>
</option>
</select>
<# } #>
</script>
<script type="text/html" id="tmpl-gallery-settings">