protected function validateImageDimension()
    {
        if (empty($this->max_image_dimensions)) {
            return true;
        }

        if (
            is_array($this->files[$this->input_file_name]) && 
            array_key_exists('tmp_name', $this->files[$this->input_file_name]) &&
            is_file($this->files[$this->input_file_name]['tmp_name'])
        ) {
            $image = getimagesize($this->files[$this->input_file_name]['tmp_name']);
            if ($image === false) {
                // this uploaded file is NOT an image. It is possible that user upload mixed file types such as text with jpeg.
                return true;
            } elseif (is_array($image) && count($image) >= 2) {
                if (
                    $image[0] <= $this->max_image_dimensions[0] &&
                    $image[1] <= $this->max_image_dimensions[1]
                ) {
                    // if image dimensions are smaller or equal to max.
                    return true;
                } elseif (
                    $image[0] <= 0 ||
                    $image[1] <= 0
                ) {
                    // Some formats may contain no image or may contain multiple images. 
                    // In these cases, getimagesize() might not be able to properly determine the image size. 
                    // getimagesize() will return zero for width and height in these cases.
                    // Reference: http://php.net/getimagesize
                    $this->setErrorMessage(
                        sprintf(static::__('The uploaded image contain no image or multiple images. (%s).'), $image[0] . 'x' . $image[1]),
                        'RDU_IMG_NO_OR_MULTIPLE_IMAGES',
                        $image[0] . 'x' . $image[1],
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                } else {
                    // if image dimensions are larger than max.
                    $this->setErrorMessage(
                        sprintf(static::__('The uploaded image dimensions are larger than allowed max dimensions. (%s &gt; %s).'), $image[0] . 'x' . $image[1], $this->max_image_dimensions[0] . 'x' . $this->max_image_dimensions[1]),
                        'RDU_IMG_DIMENSION_OVER_MAX',
                        $image[0] . 'x' . $image[1] . ' &gt; ' . $this->max_image_dimensions[0] . 'x' . $this->max_image_dimensions[1],
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                }
            } else {
                // this uploaded file is NOT an image (return array does not meet requirement). It is possible that user upload mixed file types such as text with jpeg.
                return true;
            }
        }

        return true;
    }
protected function validateImageDimension()
    {
        if (empty($this->max_image_dimensions)) {
            return true;
        }

        if (
            is_array($this->files[$this->input_file_name]) && 
            array_key_exists('tmp_name', $this->files[$this->input_file_name]) &&
            is_file($this->files[$this->input_file_name]['tmp_name'])
        ) {
            $image = getimagesize($this->files[$this->input_file_name]['tmp_name']);
            if ($image === false) {
                // this uploaded file is NOT an image. It is possible that user upload mixed file types such as text with jpeg.
                return true;
            } elseif (is_array($image) && count($image) >= 2) {
                if (
                    $image[0] <= $this->max_image_dimensions[0] &&
                    $image[1] <= $this->max_image_dimensions[1]
                ) {
                    // if image dimensions are smaller or equal to max.
                    return true;
                } elseif (
                    $image[0] <= 0 ||
                    $image[1] <= 0
                ) {
                    // Some formats may contain no image or may contain multiple images. 
                    // In these cases, getimagesize() might not be able to properly determine the image size. 
                    // getimagesize() will return zero for width and height in these cases.
                    // Reference: http://php.net/getimagesize
                    $this->setErrorMessage(
                        sprintf(static::__('The uploaded image contain no image or multiple images. (%s).'), $image[0] . 'x' . $image[1]),
                        'RDU_IMG_NO_OR_MULTIPLE_IMAGES',
                        $image[0] . 'x' . $image[1],
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                } else {
                    // if image dimensions are larger than max.
                    $this->setErrorMessage(
                        sprintf(static::__('The uploaded image dimensions are larger than allowed max dimensions. (%s &gt; %s).'), $image[0] . 'x' . $image[1], $this->max_image_dimensions[0] . 'x' . $this->max_image_dimensions[1]),
                        'RDU_IMG_DIMENSION_OVER_MAX',
                        $image[0] . 'x' . $image[1] . ' &gt; ' . $this->max_image_dimensions[0] . 'x' . $this->max_image_dimensions[1],
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                }
            } else {
                // this uploaded file is NOT an image (return array does not meet requirement). It is possible that user upload mixed file types such as text with jpeg.
                return true;
            }
        }

        return true;
    }
protected function validateImageDimension ( ) { if ( empty ( $ this -> max_image_dimensions ) ) { return true ; } if ( is_array ( $ this -> files [ $ this -> input_file_name ] ) && array_key_exists ( 'tmp_name' , $ this -> files [ $ this -> input_file_name ] ) && is_file ( $ this -> files [ $ this -> input_file_name ] [ 'tmp_name' ] ) ) { $ image = getimagesize ( $ this -> files [ $ this -> input_file_name ] [ 'tmp_name' ] ) ; if ( $ image === false ) { // this uploaded file is NOT an image. It is possible that user upload mixed file types such as text with jpeg. return true ; } elseif ( is_array ( $ image ) && count ( $ image ) >= 2 ) { if ( $ image [ 0 ] <= $ this -> max_image_dimensions [ 0 ] && $ image [ 1 ] <= $ this -> max_image_dimensions [ 1 ] ) { // if image dimensions are smaller or equal to max. return true ; } elseif ( $ image [ 0 ] <= 0 || $ image [ 1 ] <= 0 ) { // Some formats may contain no image or may contain multiple images.  // In these cases, getimagesize() might not be able to properly determine the image size.  // getimagesize() will return zero for width and height in these cases. // Reference: http://php.net/getimagesize $ this -> setErrorMessage ( sprintf ( static :: __ ( 'The uploaded image contain no image or multiple images. (%s).' ) , $ image [ 0 ] . 'x' . $ image [ 1 ] ) , 'RDU_IMG_NO_OR_MULTIPLE_IMAGES' , $ image [ 0 ] . 'x' . $ image [ 1 ] , $ this -> files [ $ this -> input_file_name ] [ 'name' ] , $ this -> files [ $ this -> input_file_name ] [ 'size' ] , $ this -> files [ $ this -> input_file_name ] [ 'type' ] ) ; return false ; } else { // if image dimensions are larger than max. $ this -> setErrorMessage ( sprintf ( static :: __ ( 'The uploaded image dimensions are larger than allowed max dimensions. (%s &gt; %s).' ) , $ image [ 0 ] . 'x' . $ image [ 1 ] , $ this -> max_image_dimensions [ 0 ] . 'x' . $ this -> max_image_dimensions [ 1 ] ) , 'RDU_IMG_DIMENSION_OVER_MAX' , $ image [ 0 ] . 'x' . $ image [ 1 ] . ' &gt; ' . $ this -> max_image_dimensions [ 0 ] . 'x' . $ this -> max_image_dimensions [ 1 ] , $ this -> files [ $ this -> input_file_name ] [ 'name' ] , $ this -> files [ $ this -> input_file_name ] [ 'size' ] , $ this -> files [ $ this -> input_file_name ] [ 'type' ] ) ; return false ; } } else { // this uploaded file is NOT an image (return array does not meet requirement). It is possible that user upload mixed file types such as text with jpeg. return true ; } } return true ; }
Validate image dimension if uploaded file is image and size is smaller than specified `max_image_dimensions`.

@return boolean Return true on success, false on failure.
Also return true on these conditions.
- No `max_image_dimensions` property set or it was set to empty array.
- The `getimagesize()` function return `false`. It means that this uploaded file is NOT an image. The developers need to validate it again one by one from uploaded files.
- Unable to find upload temp file. This is for make the upload progress passed and ready to move uploaded file. The developers need to validate it again one by one from uploaded files.
Also return false on this condition.
- The `getimagesize()` function return 0 in width and height as noted in this page ( http://php.net/getimagesize ).
Validate image dimension if uploaded file is image and size is smaller than specified max_image_dimensions .