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: https://develop.svn.wordpress.org/trunk@24055 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a77be61eb6
commit
88c8a08129
@ -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…
x
Reference in New Issue
Block a user