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;
    }