Skip to content

ImageFileValidator

ImageFileValidator verifies a parameter is an uploaded image Parameters: ‘min_width’ The minimum width of the image ‘max_width’ The maximum width of the image ‘min_height’ The minimum height of the image ‘max_height’ The maximum height of the image ‘format’ list of valid formats (gif,jpeg,png,bmp,psd,swf) Errors: ‘no_image’ The uploaded file is no image ‘min_width’ ‘max_width’ ‘min_height’ ‘max_height’ ‘format’ The image was not in the required format

class ImageFileValidator extends BaseFileValidator

ExtendsBaseFileValidator
Since1.0.0
SourceValidator/ImageFileValidator.php
MethodDescription
getAcceptedParameters(): array<int, string>Returns the file-validator parameters plus ‘min_width’, ‘max_width’, ‘min_height’, ‘max_height’ and ‘format’.

public static function getAcceptedParameters(): array<int, string>

Returns the file-validator parameters plus ‘min_width’, ‘max_width’, ‘min_height’, ‘max_height’ and ‘format’.

The four dimension parameters bound the pixel size read out of the uploaded image itself, each checked only when present. ‘format’ is a list of acceptable image formats, given either as an array or as a space-delimited string and matched case-insensitively against the extension for the detected image type, with ‘jpg’ and ‘tif’ accepted alongside the ‘jpeg’ and ‘tiff’ PHP reports. The size, extension and MIME parameters inherited from BaseFileValidator apply as well.

Returns array``<``int``, ``string``> — The accepted parameter names.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearParameters()ParameterHolderClear all parameters associated with this request.
execute()ValidatorExecutes the validator.
getArguments()ValidatorReturns all arguments which should be validated.
getBase()ValidatorReturns the base path of this validator.
getBaseKeys()ValidatorReturns the “keys” in the path of the base
getContext()ValidatorRetrieve the current application context.
getDependencyManager()ValidatorReturns the depency manager of the parent container if any.
getFlatParameterNames()ParameterHolderRetrieve an array of flattened parameter names.
getLastKey()ValidatorReturns the last “keys” in the path of the base
getMutatedRequest()ValidatorThe WebRequest this validator ended execute() with.
getName()ValidatorReturns the name of this validator.
getParameter()ParameterHolderRetrieve a parameter.
getParameterNames()ParameterHolderRetrieve an array of parameter names.
getParameters()ParameterHolderRetrieve an array of parameters.
getParentContainer()ValidatorRetrieve the parent container.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
initialize()BaseFileValidator
mapErrorCode()ValidatorConverts string severity codes into integer values (see severity constants) critical -> Validator::CRITICAL error -> Validator::ERROR notice -> Validator::NOTICE none -> Validator::NONE success -> not allowed to be specified by the user.
removeParameter()ParameterHolderRemove a parameter.
reset()ValidatorReturns the validator to its uninitialized state for reuse across requests.
setErrorMessage()ValidatorSets an error message override for the given index (the empty string is the default/generic message).
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.
setParentContainer()ValidatorSets the parent container.
shutdown()ValidatorShuts the validator down.