Neos\Media\Validator\ImageSizeValidator::isValid PHP Метод

isValid() защищенный Метод

The given $value is valid if it is an \Neos\Media\Domain\Model\ImageInterface of the configured resolution Note: a value of NULL or empty string ('') is considered valid
protected isValid ( Neos\Media\Domain\Model\ImageInterface $image ) : void
$image Neos\Media\Domain\Model\ImageInterface The image that should be validated
Результат void
    protected function isValid($image)
    {
        $this->validateOptions();
        if (!$image instanceof ImageInterface) {
            $this->addError('The given value was not an Image instance.', 1327943859);
            return;
        }
        if (isset($this->options['minimumWidth']) && $image->getWidth() < $this->options['minimumWidth']) {
            $this->addError('The actual image width of %1$d is lower than the allowed minimum width of %2$d.', 1319801362, array($image->getWidth(), $this->options['minimumWidth']));
        } elseif (isset($this->options['maximumWidth']) && $image->getWidth() > $this->options['maximumWidth']) {
            $this->addError('The actual image width of %1$d is higher than the allowed maximum width of %2$d.', 1319801859, array($image->getWidth(), $this->options['maximumWidth']));
        }
        if (isset($this->options['minimumHeight']) && $image->getHeight() < $this->options['minimumHeight']) {
            $this->addError('The actual image height of %1$d is lower than the allowed minimum height of %2$d.', 1319801925, array($image->getHeight(), $this->options['minimumHeight']));
        } elseif (isset($this->options['maximumHeight']) && $image->getHeight() > $this->options['maximumHeight']) {
            $this->addError('The actual image height of %1$d is higher than the allowed maximum height of %2$d.', 1319801929, array($image->getHeight(), $this->options['maximumHeight']));
        }
        if (isset($this->options['minimumResolution']) || isset($this->options['maximumResolution'])) {
            $resolution = $image->getWidth() * $image->getHeight();
            if (isset($this->options['minimumResolution']) && $resolution < $this->options['minimumResolution']) {
                $this->addError('The given image size of %1$d x %2$d is too low for the required minimum resolution of %3$d.', 1319813336, array($image->getHeight(), $image->getHeight(), $this->options['minimumResolution']));
            } elseif (isset($this->options['maximumResolution']) && $resolution > $this->options['maximumResolution']) {
                $this->addError('The given image size of %1$d x %2$d is too high for the required maximum resolution of %3$d.', 1319813355, array($image->getHeight(), $image->getHeight(), $this->options['maximumResolution']));
            }
        }
    }
ImageSizeValidator