Validate/File/ImageSize.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Validate
- Version
- $Id$
\Zend_Validate_File_ImageSize
Package: Zend_Validate
Returns
Validator for the image size of a image file
- Parent(s)
- \Zend_Validate_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties
array $_messageTemplates = array(self::WIDTH_TOO_BIG => "Maximum allowed width for image '%value%' should be '%maxwidth%' but '%width%' detected", self::WIDTH_TOO_SMALL => "Minimum expected width for image '%value%' should be '%minwidth%' but '%width%' detected", self::HEIGHT_TOO_BIG => "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected", self::HEIGHT_TOO_SMALL => "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected", self::NOT_DETECTED => "The size of image '%value%' could not be detected", self::NOT_READABLE => "File '%value%' is not readable or does not exist")
Error message template
Default value
array(self::WIDTH_TOO_BIG => "Maximum allowed width for image '%value%' should be '%maxwidth%' but '%width%' detected", self::WIDTH_TOO_SMALL => "Minimum expected width for image '%value%' should be '%minwidth%' but '%width%' detected", self::HEIGHT_TOO_BIG => "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected", self::HEIGHT_TOO_SMALL => "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected", self::NOT_DETECTED => "The size of image '%value%' could not be detected", self::NOT_READABLE => "File '%value%' is not readable or does not exist")
Details- Type
- array
array $_messageVariables = array('minwidth' => '_minwidth', 'maxwidth' => '_maxwidth', 'minheight' => '_minheight', 'maxheight' => '_maxheight', 'width' => '_width', 'height' => '_height')
Error message template variables
Default value
array('minwidth' => '_minwidth', 'maxwidth' => '_maxwidth', 'minheight' => '_minheight', 'maxheight' => '_maxheight', 'width' => '_width', 'height' => '_height')
Details- Type
- array
Methods
__construct(\Zend_Config | array $options) : void
Sets validator options
Accepts the following option keys:
- minheight
- minwidth
- maxheight
- maxwidth
ParametersName | Type | Description |
---|---|---|
$options | \Zend_Config | array |
_throw(string $file, string $errorType) : false
Throws an error of the given type
Parameters
Returns
Name | Type | Description |
---|---|---|
$file | string | |
$errorType | string |
Type | Description |
---|---|
false |
isValid(string $value, array $file = null) : boolean
Defined by Zend_Validate_Interface
Returns true if and only if the imagesize of $value is at least min and
not bigger than max
ParametersName | Type | Description |
---|---|---|
$value | string | Real file to check for image size |
$file | array | File data from Zend_File_Transfer |
Type | Description |
---|---|
boolean |
setImageHeight(array $options) : \Zend_Validate_File_ImageSize
Sets the mimimum and maximum image height
Parameters
Returns
Name | Type | Description |
---|---|---|
$options | array | The image height dimensions |
Type | Description |
---|---|
\Zend_Validate_File_ImageSize | Provides a fluent interface |
setImageMax(array $options) : \Zend_Validate_StringLength
Sets the maximum image size
Parameters
Returns
Throws
Name | Type | Description |
---|---|---|
$options | array | The maximum image dimensions |
Type | Description |
---|---|
\Zend_Validate_StringLength | Provides a fluent interface |
Exception | Description |
---|---|
\Zend_Validate_Exception | When maxwidth is smaller than minwidth |
\Zend_Validate_Exception | When maxheight is smaller than minheight |
setImageMin(array $options) : \Zend_Validate_File_ImageSize
Sets the minimum image size
Parameters
Returns
Throws
Name | Type | Description |
---|---|---|
$options | array | The minimum image dimensions |
Type | Description |
---|---|
\Zend_Validate_File_ImageSize | Provides a fluent interface |
Exception | Description |
---|---|
\Zend_Validate_Exception | When minwidth is greater than maxwidth |
\Zend_Validate_Exception | When minheight is greater than maxheight |
setImageWidth(array $options) : \Zend_Validate_File_ImageSize
Sets the mimimum and maximum image width
Parameters
Returns
Name | Type | Description |
---|---|---|
$options | array | The image width dimensions |
Type | Description |
---|---|
\Zend_Validate_File_ImageSize | Provides a fluent interface |