Make WordPress Core

Ticket #26823: multi_resize_null_support.patch

File multi_resize_null_support.patch, 2.9 KB (added by pbearne, 11 years ago)

Patch for multi_resize_null_support

  • wp-includes/class-wp-image-editor-gd.php

     
    193193         *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
    194194         *
    195195         *     @type array $size {
    196          *         @type int  $width  Image width.
    197          *         @type int  $height Image height.
     196         *         @type int/null  $width  Image width.
     197         *         @type int/null  $height Image height.
    198198         *         @type bool $crop   Optional. Whether to crop the image. Default false.
    199199         *     }
    200200         * }
     
    205205                $orig_size = $this->size;
    206206
    207207                foreach ( $sizes as $size => $size_data ) {
    208                         if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) )
    209                                 continue;
     208                        //  are both width and height set
     209                        if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) ){
     210                                // check both aren't null
     211                                if( null === $size_data['width'] &&  null === $size_data['height']){
     212                                        continue;
     213                                }
    210214
     215                                // if check that only width is null and set to max int if so
     216                                if( null === $size_data['width'] ){
     217                                        $size_data['width'] = PHP_INT_MAX-1;
     218                                }
     219                                // if check that only height is null and set to max int if so
     220                                if ( null === $size_data['height'] ){
     221                                        $size_data['height'] = PHP_INT_MAX-1;
     222                                }
     223                        }
     224
    211225                        if ( ! isset( $size_data['crop'] ) )
    212226                                $size_data['crop'] = false;
    213227
  • wp-includes/class-wp-image-editor-imagick.php

     
    256256         *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
    257257         *
    258258         *     @type array $size {
    259          *         @type int  $width  Image width.
    260          *         @type int  $height Image height.
     259         *         @type int/null  $width  Image width.
     260         *         @type int/null  $height Image height.
    261261         *         @type bool $crop   Optional. Whether to crop the image. Default false.
    262262         *     }
    263263         * }
     
    272272                        if ( ! $this->image )
    273273                                $this->image = $orig_image->getImage();
    274274
    275                         if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) )
    276                                 continue;
     275                        if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) ){
     276                                // check both aren't null
     277                                if( null === $size_data['width'] &&  null === $size_data['height']){
     278                                        continue;
     279                                }
    277280
     281                                // if check that only width is null and set to max int if so
     282                                if( null === $size_data['width'] ){
     283                                        $size_data['width'] = PHP_INT_MAX-1;
     284                                }
     285                                // if check that only height is null and set to max int if so
     286                                if ( null === $size_data['height'] ){
     287                                        $size_data['height'] = PHP_INT_MAX-1;
     288                                }
     289                        }
     290
    278291                        if ( ! isset( $size_data['crop'] ) )
    279292                                $size_data['crop'] = false;
    280293