- Модуль: ui
- Путь к файлу: ~/bitrix/modules/ui/lib/FileUploader/Configuration.php
- Класс: BitrixUIFileUploaderConfiguration
- Вызов: Configuration::validateImage
public function validateImage(FileData $fileData): Result
{
$result = new Result();
if (($fileData->getWidth() === 0 || $fileData->getHeight() === 0) && !$this->getIgnoreUnknownImageTypes())
{
return $result->addError(new UploaderError(UploaderError::IMAGE_TYPE_NOT_SUPPORTED));
}
if ($this->getImageMaxFileSize() !== null && $fileData->getSize() > $this->getImageMaxFileSize())
{
return $result->addError(
new UploaderError(
UploaderError::IMAGE_MAX_FILE_SIZE_EXCEEDED,
[
'imageMaxFileSize' => CFile::formatSize($this->getImageMaxFileSize()),
'imageMaxFileSizeInBytes' => $this->getImageMaxFileSize(),
]
)
);
}
if ($fileData->getSize() < $this->getImageMinFileSize())
{
return $result->addError(
new UploaderError(
UploaderError::IMAGE_MIN_FILE_SIZE_EXCEEDED,
[
'imageMinFileSize' => CFile::formatSize($this->getImageMinFileSize()),
'imageMinFileSizeInBytes' => $this->getImageMinFileSize(),
]
)
);
}
if ($fileData->getWidth() < $this->getImageMinWidth() || $fileData->getHeight() < $this->getImageMinHeight())
{
return $result->addError(
new UploaderError(
UploaderError::IMAGE_IS_TOO_SMALL,
[
'minWidth' => $this->getImageMinWidth(),
'minHeight' => $this->getImageMinHeight(),
]
)
);
}
if ($fileData->getWidth() > $this->getImageMaxWidth() || $fileData->getHeight() > $this->getImageMaxHeight())
{
return $result->addError(
new UploaderError(
UploaderError::IMAGE_IS_TOO_BIG,
[
'maxWidth' => $this->getImageMaxWidth(),
'maxHeight' => $this->getImageMaxHeight(),
]
)
);
}
return $result;
}