Header Images: Add suggested dimensions to the media workflow.
props ehg, gcorne. see #21785. Built from https://develop.svn.wordpress.org/trunk@28030 git-svn-id: http://core.svn.wordpress.org/trunk@27860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
131c940cf8
commit
6b41f728d4
|
@ -419,16 +419,10 @@
|
||||||
* @param {event} event
|
* @param {event} event
|
||||||
*/
|
*/
|
||||||
openMedia: function(event) {
|
openMedia: function(event) {
|
||||||
var suggestedWidth, suggestedHeight,
|
var l10n = _wpMediaViewsL10n;
|
||||||
l10n = _wpMediaViewsL10n;
|
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
suggestedWidth = l10n.suggestedWidth.replace('%d', _wpCustomizeHeader.data.width);
|
|
||||||
suggestedHeight = l10n.suggestedHeight.replace('%d', _wpCustomizeHeader.data.height);
|
|
||||||
|
|
||||||
/* '<span class="suggested-dimensions">' + suggestedWidth + ' ' + suggestedHeight + '</span>' */
|
|
||||||
|
|
||||||
this.frame = wp.media({
|
this.frame = wp.media({
|
||||||
title: l10n.chooseImage,
|
title: l10n.chooseImage,
|
||||||
library: {
|
library: {
|
||||||
|
@ -439,7 +433,11 @@
|
||||||
close: false
|
close: false
|
||||||
},
|
},
|
||||||
multiple: false,
|
multiple: false,
|
||||||
imgSelectOptions: this.calculateImageSelectOptions
|
crop: {
|
||||||
|
suggestedWidth: _wpCustomizeHeader.data.width,
|
||||||
|
suggestedHeight: _wpCustomizeHeader.data.height,
|
||||||
|
imgSelectOptions: this.calculateImageSelectOptions
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.frame.states.add([new wp.media.controller.Cropper()]);
|
this.frame.states.add([new wp.media.controller.Cropper()]);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -929,6 +929,7 @@
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #666;
|
color: #666;
|
||||||
|
margin-left: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -929,6 +929,7 @@
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #666;
|
color: #666;
|
||||||
|
margin-right: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3312,6 +3312,16 @@
|
||||||
}) );
|
}) );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
prepare: function() {
|
||||||
|
var cropOptions = this.controller.options.crop;
|
||||||
|
if ( cropOptions ) {
|
||||||
|
return {
|
||||||
|
suggestedWidth: cropOptions.suggestedWidth,
|
||||||
|
suggestedHeight: cropOptions.suggestedHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @returns {wp.media.view.UploaderInline} Returns itself to allow chaining
|
* @returns {wp.media.view.UploaderInline} Returns itself to allow chaining
|
||||||
*/
|
*/
|
||||||
|
@ -5154,7 +5164,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
createToolbar: function() {
|
createToolbar: function() {
|
||||||
var filters, FiltersConstructor;
|
var filters, FiltersConstructor,
|
||||||
|
frameOptions = this.controller.options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @member {wp.media.view.Toolbar}
|
* @member {wp.media.view.Toolbar}
|
||||||
|
@ -5198,6 +5209,13 @@
|
||||||
priority: -40
|
priority: -40
|
||||||
}) );
|
}) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( frameOptions.crop ) {
|
||||||
|
this.toolbar.set( 'suggestedDimensions', new media.View({
|
||||||
|
el: $( '<div class="instructions">' + l10n.suggestedDimensions + ' ' + frameOptions.crop.suggestedWidth + ' × ' + frameOptions.crop.suggestedHeight + '</div>' )[0],
|
||||||
|
priority: -40
|
||||||
|
}) );
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateContent: function() {
|
updateContent: function() {
|
||||||
|
@ -6230,7 +6248,7 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onImageLoad: function() {
|
onImageLoad: function() {
|
||||||
var imgOptions = this.controller.frame.options.imgSelectOptions;
|
var imgOptions = this.controller.frame.options.crop.imgSelectOptions;
|
||||||
if (typeof imgOptions === 'function') {
|
if (typeof imgOptions === 'function') {
|
||||||
imgOptions = imgOptions(this.options.attachment, this.controller);
|
imgOptions = imgOptions(this.options.attachment, this.controller);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -205,6 +205,12 @@ function wp_print_media_templates() {
|
||||||
printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($byte_sizes[$u]) );
|
printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($byte_sizes[$u]) );
|
||||||
?></p>
|
?></p>
|
||||||
|
|
||||||
|
<# if ( data.suggestedWidth && data.suggestedHeight ) { #>
|
||||||
|
<p class="suggested-dimensions">
|
||||||
|
<?php _e( 'Suggested image dimensions:' ); ?> {{{data.suggestedWidth}}} × {{{data.suggestedHeight}}}
|
||||||
|
</p>
|
||||||
|
<# } #>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
/** This action is documented in wp-admin/includes/media.php */
|
/** This action is documented in wp-admin/includes/media.php */
|
||||||
do_action( 'post-upload-ui' ); ?>
|
do_action( 'post-upload-ui' ); ?>
|
||||||
|
|
|
@ -2525,8 +2525,7 @@ function wp_enqueue_media( $args = array() ) {
|
||||||
'cropImage' => __( 'Crop Image' ),
|
'cropImage' => __( 'Crop Image' ),
|
||||||
'cropYourImage' => __( 'Crop your image' ),
|
'cropYourImage' => __( 'Crop your image' ),
|
||||||
'cropping' => __( 'Cropping…' ),
|
'cropping' => __( 'Cropping…' ),
|
||||||
'suggestedWidth' => __( 'Suggested width is %d pixels.' ),
|
'suggestedDimensions' => __( 'Suggested image dimensions:' ),
|
||||||
'suggestedHeight' => __( 'Suggested height is %d pixels.' ),
|
|
||||||
'cropError' => __( 'There has been an error cropping your image.' ),
|
'cropError' => __( 'There has been an error cropping your image.' ),
|
||||||
|
|
||||||
// Edit Audio
|
// Edit Audio
|
||||||
|
|
Loading…
Reference in New Issue