Image editors: multi_resize() should require height and width. Crop is now optional and defaults to false. props DH-Shredder. fixes #23884.
git-svn-id: http://core.svn.wordpress.org/trunk@24055 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4c4147a322
commit
feffc2716f
|
@ -178,10 +178,13 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
|||
* Processes current image and saves to disk
|
||||
* multiple sizes from single source.
|
||||
*
|
||||
* 'width' and 'height' are required.
|
||||
* 'crop' defaults to false when not provided.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $sizes { {'width'=>int, 'height'=>int, 'crop'=>bool}, ... }
|
||||
* @param array $sizes { {'width'=>int, 'height'=>int, ['crop'=>bool]}, ... }
|
||||
* @return array
|
||||
*/
|
||||
public function multi_resize( $sizes ) {
|
||||
|
@ -189,6 +192,12 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
|||
$orig_size = $this->size;
|
||||
|
||||
foreach ( $sizes as $size => $size_data ) {
|
||||
if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) )
|
||||
continue;
|
||||
|
||||
if ( ! isset( $size_data['crop'] ) )
|
||||
$size_data['crop'] = false;
|
||||
|
||||
$image = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
|
||||
|
||||
if( ! is_wp_error( $image ) ) {
|
||||
|
|
|
@ -245,10 +245,13 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
|||
* Processes current image and saves to disk
|
||||
* multiple sizes from single source.
|
||||
*
|
||||
* 'width' and 'height' are required.
|
||||
* 'crop' defaults to false when not provided.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $sizes { {'width'=>int, 'height'=>int, 'crop'=>bool}, ... }
|
||||
* @param array $sizes { {'width'=>int, 'height'=>int, ['crop'=>bool]}, ... }
|
||||
* @return array
|
||||
*/
|
||||
public function multi_resize( $sizes ) {
|
||||
|
@ -260,6 +263,12 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
|||
if ( ! $this->image )
|
||||
$this->image = $orig_image->getImage();
|
||||
|
||||
if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) )
|
||||
continue;
|
||||
|
||||
if ( ! isset( $size_data['crop'] ) )
|
||||
$size_data['crop'] = false;
|
||||
|
||||
$resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
|
||||
|
||||
if( ! is_wp_error( $resize_result ) ) {
|
||||
|
|
|
@ -97,11 +97,14 @@ abstract class WP_Image_Editor {
|
|||
* Processes current image and saves to disk
|
||||
* multiple sizes from single source.
|
||||
*
|
||||
* 'width' and 'height' are required.
|
||||
* 'crop' defaults to false when not provided.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @access public
|
||||
* @abstract
|
||||
*
|
||||
* @param array $sizes { {'width'=>int, 'height'=>int, 'crop'=>bool}, ... }
|
||||
* @param array $sizes { {'width'=>int, 'height'=>int, ['crop'=>bool]}, ... }
|
||||
* @return array
|
||||
*/
|
||||
abstract public function multi_resize( $sizes );
|
||||
|
|
Loading…
Reference in New Issue