Media: add a new image size, medium_large. Bumps db version to add new options.

Adds unit tests.

Props DH-Shredder, joemcgill, azaozz.
Fixes #34196.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor
2015-10-31 20:50:25 +00:00
parent 382d455235
commit d8eacd51d8
8 changed files with 35 additions and 10 deletions

View File

@@ -212,7 +212,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
* @access public
*
* @param array $sizes {
* An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
* An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
*
* Either a height or width must be provided.
* If one of the two is set to null, the resize will

View File

@@ -270,7 +270,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
* @access public
*
* @param array $sizes {
* An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
* An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
*
* Either a height or width must be provided.
* If one of the two is set to null, the resize will

View File

@@ -513,6 +513,16 @@ class wp_xmlrpc_server extends IXR_Server {
'readonly' => false,
'option' => 'medium_size_h'
),
'medium_large_size_w' => array(
'desc' => __( 'Medium-Large size image width' ),
'readonly' => false,
'option' => 'medium_large_size_w'
),
'medium_large_size_h' => array(
'desc' => __( 'Medium-Large size image height' ),
'readonly' => false,
'option' => 'medium_large_size_h'
),
'large_size_w' => array(
'desc' => __( 'Large size image width' ),
'readonly' => false,

View File

@@ -3662,6 +3662,8 @@ function sanitize_option( $option, $value ) {
case 'thumbnail_size_h':
case 'medium_size_w':
case 'medium_size_h':
case 'medium_large_size_w':
case 'medium_large_size_h':
case 'large_size_w':
case 'large_size_h':
case 'mailserver_port':

View File

@@ -14,7 +14,7 @@
* The `$size` parameter accepts either an array or a string. The supported string
* values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at
* 128 width and 96 height in pixels. Also supported for the string value is
* 'medium' and 'full'. The 'full' isn't actually supported, but any value other
* 'medium', 'medium_large' and 'full'. The 'full' isn't actually supported, but any value other
* than the supported will result in the content_width size or 500 if that is
* not set.
*
@@ -60,7 +60,15 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co
elseif ( $size == 'medium' ) {
$max_width = intval(get_option('medium_size_w'));
$max_height = intval(get_option('medium_size_h'));
// if no width is set, default to the theme content width if available
}
elseif ( $size == 'medium_large' ) {
$max_width = intval( get_option( 'medium_large_size_w' ) );
$max_height = intval( get_option( 'medium_large_size_h' ) );
if ( intval( $content_width ) > 0 ) {
$max_width = min( intval( $content_width ), $max_width );
}
}
elseif ( $size == 'large' ) {
/*
@@ -71,8 +79,9 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co
*/
$max_width = intval(get_option('large_size_w'));
$max_height = intval(get_option('large_size_h'));
if ( intval($content_width) > 0 )
if ( intval($content_width) > 0 ) {
$max_width = min( intval($content_width), $max_width );
}
} elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) {
$max_width = intval( $_wp_additional_image_sizes[$size]['width'] );
$max_height = intval( $_wp_additional_image_sizes[$size]['height'] );
@@ -706,7 +715,7 @@ function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) {
*/
function get_intermediate_image_sizes() {
global $_wp_additional_image_sizes;
$image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
$image_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); // Standard sizes
if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
$image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
@@ -716,7 +725,7 @@ function get_intermediate_image_sizes() {
* @since 2.5.0
*
* @param array $image_sizes An array of intermediate image sizes. Defaults
* are 'thumbnail', 'medium', 'large'.
* are 'thumbnail', 'medium', 'medium_large', 'large'.
*/
return apply_filters( 'intermediate_image_sizes', $image_sizes );
}

View File

@@ -4,14 +4,14 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-beta2-35478';
$wp_version = '4.4-beta2-35479';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
*
* @global int $wp_db_version
*/
$wp_db_version = 35329;
$wp_db_version = 35465;
/**
* Holds the TinyMCE version