PHP Class yii\validators\ImageValidator

Since: 2.0
Author: Taras Gudz ([email protected])
Inheritance: extends FileValidator
Show file Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$maxHeight the maximum width in pixels. Defaults to null, meaning no limit.
$maxWidth the maximum width in pixels. Defaults to null, meaning no limit.
$minHeight the minimum height in pixels. Defaults to null, meaning no limit.
$minWidth the minimum width in pixels. Defaults to null, meaning no limit.
$notImage the error message used when the uploaded file is not an image. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name
$overHeight the error message used when the image is over [[maxHeight]]. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name - {limit}: the value of [[maxHeight]]
$overWidth the error message used when the image is over [[maxWidth]]. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name - {limit}: the value of [[maxWidth]]
$underHeight the error message used when the image is under [[minHeight]]. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name - {limit}: the value of [[minHeight]]
$underWidth the error message used when the image is under [[minWidth]]. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name - {limit}: the value of [[minWidth]]

Public Methods

Method Description
clientValidateAttribute ( $model, $attribute, $view )
init ( )

Protected Methods

Method Description
getClientOptions ( $model, $attribute )
validateImage ( UploadedFile $image ) : array | null Validates an image file.
validateValue ( $value )

Method Details

clientValidateAttribute() public method

public clientValidateAttribute ( $model, $attribute, $view )

getClientOptions() protected method

protected getClientOptions ( $model, $attribute )

init() public method

public init ( )

validateImage() protected method

Validates an image file.
protected validateImage ( UploadedFile $image ) : array | null
$image yii\web\UploadedFile uploaded file passed to check against a set of rules
return array | null the error message and the parameters to be inserted into the error message. Null should be returned if the data is valid.

validateValue() protected method

protected validateValue ( $value )

Property Details

$maxHeight public property

the maximum width in pixels. Defaults to null, meaning no limit.
See also: overWidth for the customized message used when image height is too big.
public $maxHeight

$maxWidth public property

the maximum width in pixels. Defaults to null, meaning no limit.
See also: overWidth for the customized message used when image width is too big.
public $maxWidth

$minHeight public property

the minimum height in pixels. Defaults to null, meaning no limit.
See also: underHeight for the customized message used when image height is too small.
public $minHeight

$minWidth public property

the minimum width in pixels. Defaults to null, meaning no limit.
See also: underWidth for the customized message used when image width is too small.
public $minWidth

$notImage public property

the error message used when the uploaded file is not an image. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name
public $notImage

$overHeight public property

the error message used when the image is over [[maxHeight]]. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name - {limit}: the value of [[maxHeight]]
public $overHeight

$overWidth public property

the error message used when the image is over [[maxWidth]]. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name - {limit}: the value of [[maxWidth]]
public $overWidth

$underHeight public property

the error message used when the image is under [[minHeight]]. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name - {limit}: the value of [[minHeight]]
public $underHeight

$underWidth public property

the error message used when the image is under [[minWidth]]. You may use the following tokens in the message: - {attribute}: the attribute name - {file}: the uploaded file name - {limit}: the value of [[minWidth]]
public $underWidth