function Image::__construct
Same name in this branch
- 11.1.x vendor/symfony/dom-crawler/Image.php \Symfony\Component\DomCrawler\Image::__construct()
- 11.1.x core/lib/Drupal/Core/Image/Image.php \Drupal\Core\Image\Image::__construct()
- 11.1.x core/modules/media/src/Plugin/media/Source/Image.php \Drupal\media\Plugin\media\Source\Image::__construct()
Parameters
array<string,mixed>|null $options:
positive-int|string|null $maxSize The max size of the underlying file:
bool|null $binaryFormat Pass true to use binary-prefixed units (KiB, MiB, etc.) or false to use SI-prefixed units (kB, MB) in displayed messages. Pass null to guess the format from the maxSize option. (defaults to null):
non-empty-string[]|null $mimeTypes Acceptable media types:
positive-int|null $filenameMaxLength Maximum length of the file name:
string|null $disallowEmptyMessage Enable empty upload validation with this message in case of error:
string|null $uploadIniSizeErrorMessage Message if the file size exceeds the max size configured in php.ini:
string|null $uploadFormSizeErrorMessage Message if the file size exceeds the max size configured in the HTML input field:
string|null $uploadPartialErrorMessage Message if the file is only partially uploaded:
string|null $uploadNoTmpDirErrorMessage Message if there is no upload_tmp_dir in php.ini:
string|null $uploadCantWriteErrorMessage Message if the uploaded file can not be stored in the temporary directory:
string|null $uploadErrorMessage Message if an unknown error occurred on upload:
string[]|null $groups:
int<0, int>|null $minWidth Minimum image width:
positive-int|null $maxWidth Maximum image width:
positive-int|null $maxHeight Maximum image height:
int<0, int>|null $minHeight Minimum image weight:
positive-int|float|null $maxRatio Maximum image ratio:
int<0, max>|float|null $minRatio Minimum image ration:
int<0, max>|float|null $minPixels Minimum amount of pixels:
positive-int|float|null $maxPixels Maximum amount of pixels:
bool|null $allowSquare Whether to allow a square image (defaults to true):
bool|null $allowLandscape Whether to allow a landscape image (defaults to true):
bool|null $allowPortrait Whether to allow a portrait image (defaults to true):
bool|null $detectCorrupted Whether to validate the image is not corrupted (defaults to false):
string|null $sizeNotDetectedMessage Message if the system can not determine image size and there is a size constraint to validate:
Overrides File::__construct
See also
https://www.iana.org/assignments/media-types/media-types.xhtml Existing media types
File
-
vendor/
symfony/ validator/ Constraints/ Image.php, line 121
Class
- Image
- Validates that a file (or a path to a file) is a valid image.
Namespace
Symfony\Component\Validator\ConstraintsCode
public function __construct(?array $options = null, int|string|null $maxSize = null, ?bool $binaryFormat = null, ?array $mimeTypes = null, ?int $filenameMaxLength = null, ?int $minWidth = null, ?int $maxWidth = null, ?int $maxHeight = null, ?int $minHeight = null, int|float|null $maxRatio = null, int|float|null $minRatio = null, int|float|null $minPixels = null, int|float|null $maxPixels = null, ?bool $allowSquare = null, ?bool $allowLandscape = null, ?bool $allowPortrait = null, ?bool $detectCorrupted = null, ?string $notFoundMessage = null, ?string $notReadableMessage = null, ?string $maxSizeMessage = null, ?string $mimeTypesMessage = null, ?string $disallowEmptyMessage = null, ?string $filenameTooLongMessage = null, ?string $uploadIniSizeErrorMessage = null, ?string $uploadFormSizeErrorMessage = null, ?string $uploadPartialErrorMessage = null, ?string $uploadNoFileErrorMessage = null, ?string $uploadNoTmpDirErrorMessage = null, ?string $uploadCantWriteErrorMessage = null, ?string $uploadExtensionErrorMessage = null, ?string $uploadErrorMessage = null, ?string $sizeNotDetectedMessage = null, ?string $maxWidthMessage = null, ?string $minWidthMessage = null, ?string $maxHeightMessage = null, ?string $minHeightMessage = null, ?string $minPixelsMessage = null, ?string $maxPixelsMessage = null, ?string $maxRatioMessage = null, ?string $minRatioMessage = null, ?string $allowSquareMessage = null, ?string $allowLandscapeMessage = null, ?string $allowPortraitMessage = null, ?string $corruptedMessage = null, ?array $groups = null, mixed $payload = null) {
parent::__construct($options, $maxSize, $binaryFormat, $mimeTypes, $filenameMaxLength, $notFoundMessage, $notReadableMessage, $maxSizeMessage, $mimeTypesMessage, $disallowEmptyMessage, $filenameTooLongMessage, $uploadIniSizeErrorMessage, $uploadFormSizeErrorMessage, $uploadPartialErrorMessage, $uploadNoFileErrorMessage, $uploadNoTmpDirErrorMessage, $uploadCantWriteErrorMessage, $uploadExtensionErrorMessage, $uploadErrorMessage, $groups, $payload);
$this->minWidth = $minWidth ?? $this->minWidth;
$this->maxWidth = $maxWidth ?? $this->maxWidth;
$this->maxHeight = $maxHeight ?? $this->maxHeight;
$this->minHeight = $minHeight ?? $this->minHeight;
$this->maxRatio = $maxRatio ?? $this->maxRatio;
$this->minRatio = $minRatio ?? $this->minRatio;
$this->minPixels = $minPixels ?? $this->minPixels;
$this->maxPixels = $maxPixels ?? $this->maxPixels;
$this->allowSquare = $allowSquare ?? $this->allowSquare;
$this->allowLandscape = $allowLandscape ?? $this->allowLandscape;
$this->allowPortrait = $allowPortrait ?? $this->allowPortrait;
$this->detectCorrupted = $detectCorrupted ?? $this->detectCorrupted;
$this->sizeNotDetectedMessage = $sizeNotDetectedMessage ?? $this->sizeNotDetectedMessage;
$this->maxWidthMessage = $maxWidthMessage ?? $this->maxWidthMessage;
$this->minWidthMessage = $minWidthMessage ?? $this->minWidthMessage;
$this->maxHeightMessage = $maxHeightMessage ?? $this->maxHeightMessage;
$this->minHeightMessage = $minHeightMessage ?? $this->minHeightMessage;
$this->minPixelsMessage = $minPixelsMessage ?? $this->minPixelsMessage;
$this->maxPixelsMessage = $maxPixelsMessage ?? $this->maxPixelsMessage;
$this->maxRatioMessage = $maxRatioMessage ?? $this->maxRatioMessage;
$this->minRatioMessage = $minRatioMessage ?? $this->minRatioMessage;
$this->allowSquareMessage = $allowSquareMessage ?? $this->allowSquareMessage;
$this->allowLandscapeMessage = $allowLandscapeMessage ?? $this->allowLandscapeMessage;
$this->allowPortraitMessage = $allowPortraitMessage ?? $this->allowPortraitMessage;
$this->corruptedMessage = $corruptedMessage ?? $this->corruptedMessage;
if (!\in_array('image/*', (array) $this->mimeTypes, true) && !\array_key_exists('mimeTypesMessage', $options ?? []) && null === $mimeTypesMessage) {
$this->mimeTypesMessage = 'The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}.';
}
}