Media: Improve image size-related UI and code.

* Add dimensions to the "sizes" dropdown.
* Ensure a `full` size is generated in `wp_prepare_attachment_for_js()`.
* Print the dimensions for the full size in the attachment summary (instead of those for the current size).
* When generating the attachment view's template, map `imageSize()` to the `size` property instead of overriding the default data.

see #21390.


git-svn-id: http://core.svn.wordpress.org/trunk@22580 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-14 22:08:02 +00:00
parent 502a3cca14
commit 8227b30046
2 changed files with 14 additions and 19 deletions

View File

@ -2139,7 +2139,7 @@
options.describe = this.controller.state().get('describe'); options.describe = this.controller.state().get('describe');
if ( 'image' === options.type ) if ( 'image' === options.type )
_.extend( options, this.imageSize() ); options.size = this.imageSize();
this.$el.html( this.template( options ) ); this.$el.html( this.template( options ) );

View File

@ -1280,12 +1280,14 @@ function wp_prepare_attachment_for_js( $attachment ) {
} }
} }
$response = array_merge( $response, array( $sizes['full'] = array(
'height' => $meta['height'], 'height' => $meta['height'],
'width' => $meta['width'], 'width' => $meta['width'],
'sizes' => $sizes, 'url' => $attachment_url,
'orientation' => $meta['height'] > $meta['width'] ? 'portrait' : 'landscape', 'orientation' => $meta['height'] > $meta['width'] ? 'portrait' : 'landscape',
) ); );
$response = array_merge( $response, array( 'sizes' => $sizes ), $sizes['full'] );
} }
if ( function_exists('get_compat_media_markup') ) if ( function_exists('get_compat_media_markup') )
@ -1430,7 +1432,7 @@ function wp_print_media_templates( $attachment ) {
<# } else if ( 'image' === data.type ) { #> <# } else if ( 'image' === data.type ) { #>
<div class="thumbnail"> <div class="thumbnail">
<div class="centered"> <div class="centered">
<img src="{{ data.url }}" draggable="false" /> <img src="{{ data.size.url }}" draggable="false" />
</div> </div>
</div> </div>
<# } else { #> <# } else { #>
@ -1468,7 +1470,7 @@ function wp_print_media_templates( $attachment ) {
<# if ( data.uploading ) { #> <# if ( data.uploading ) { #>
<div class="media-progress-bar"><div></div></div> <div class="media-progress-bar"><div></div></div>
<# } else if ( 'image' === data.type ) { #> <# } else if ( 'image' === data.type ) { #>
<img src="{{ data.url }}" draggable="false" /> <img src="{{ data.size.url }}" draggable="false" />
<# } else { #> <# } else { #>
<img src="{{ data.icon }}" class="icon" draggable="false" /> <img src="{{ data.icon }}" class="icon" draggable="false" />
<# } #> <# } #>
@ -1609,22 +1611,15 @@ function wp_print_media_templates( $attachment ) {
'full' => __('Full Size'), 'full' => __('Full Size'),
) ); ) );
foreach ( $sizes as $value => $name ) : foreach ( $sizes as $value => $name ) : ?>
if ( 'full' === $name ) <#
continue; var size = data.sizes['<?php echo esc_js( $value ); ?>'];
?> if ( size ) { #>
<# if ( data.sizes['<?php echo esc_js( $value ); ?>'] ) { #>
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'medium' ); ?>> <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'medium' ); ?>>
<?php echo esc_html( $name ); ?> <?php echo esc_html( $name ); ?> &ndash; {{ size.width }} &times; {{ size.height }}
</option> </option>
<# } #>> <# } #>>
<?php endforeach; <?php endforeach; ?>
if ( ! empty( $sizes['full'] ) ) : ?>
<option value="full">
<?php echo esc_html( $sizes['full'] ); ?>
</option>
<?php endif; ?>
</select> </select>
</label> </label>
<# } #> <# } #>