Validate/File/ImageSize.php

Show: PublicProtectedPrivateinherited
Table of Contents
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
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

>VConstant  WIDTH_TOO_BIG = 'fileImageSizeWidthTooBig'
Const
string Error constants  
>VConstant  WIDTH_TOO_SMALL = 'fileImageSizeWidthTooSmall'
>VConstant  HEIGHT_TOO_BIG = 'fileImageSizeHeightTooBig'
>VConstant  HEIGHT_TOO_SMALL = 'fileImageSizeHeightTooSmall'
>VConstant  NOT_DETECTED = 'fileImageSizeNotDetected'
>VConstant  NOT_READABLE = 'fileImageSizeNotReadable'

Properties

>VPropertyprotectedinteger $_height
Detected height
Details
Type
integer
>VPropertyprotectedinteger $_maxheight
Maximum image height
Details
Type
integer
>VPropertyprotectedinteger $_maxwidth
Maximum image width
Details
Type
integer
>VPropertyprotectedarray $_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 valuearray(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
>VPropertyprotectedarray $_messageVariables = array('minwidth' => '_minwidth', 'maxwidth' => '_maxwidth', 'minheight' => '_minheight', 'maxheight' => '_maxheight', 'width' => '_width', 'height' => '_height')

Error message template variables

Default valuearray('minwidth' => '_minwidth', 'maxwidth' => '_maxwidth', 'minheight' => '_minheight', 'maxheight' => '_maxheight', 'width' => '_width', 'height' => '_height')Details
Type
array
>VPropertyprotectedinteger $_minheight
Minimum image height
Details
Type
integer
>VPropertyprotectedinteger $_minwidth
Minimum image width
Details
Type
integer
>VPropertyprotectedinteger $_width
Detected width
Details
Type
integer

Methods

methodpublic__construct(\Zend_Config | array $options) : void

Sets validator options

Accepts the following option keys: - minheight - minwidth - maxheight - maxwidth
Parameters
NameTypeDescription
$options\Zend_Config | array
methodprotected_throw(string $file, string $errorType) : false

Throws an error of the given type

Parameters
NameTypeDescription
$filestring
$errorTypestring
Returns
TypeDescription
false
methodpublicgetImageHeight() : array

Returns the set image height sizes

Returns
TypeDescription
array
methodpublicgetImageMax() : array

Returns the set maximum image sizes

Returns
TypeDescription
array
methodpublicgetImageMin() : array

Returns the set minimum image sizes

Returns
TypeDescription
array
methodpublicgetImageWidth() : array

Returns the set image width sizes

Returns
TypeDescription
array
methodpublicisValid(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
Parameters
NameTypeDescription
$valuestring

Real file to check for image size

$filearray

File data from Zend_File_Transfer

Returns
TypeDescription
boolean
methodpublicsetImageHeight(array $options) : \Zend_Validate_File_ImageSize

Sets the mimimum and maximum image height

Parameters
NameTypeDescription
$optionsarray

The image height dimensions

Returns
TypeDescription
\Zend_Validate_File_ImageSizeProvides a fluent interface
methodpublicsetImageMax(array $options) : \Zend_Validate_StringLength

Sets the maximum image size

Parameters
NameTypeDescription
$optionsarray

The maximum image dimensions

Returns
TypeDescription
\Zend_Validate_StringLengthProvides a fluent interface
Throws
ExceptionDescription
\Zend_Validate_ExceptionWhen maxwidth is smaller than minwidth
\Zend_Validate_ExceptionWhen maxheight is smaller than minheight
methodpublicsetImageMin(array $options) : \Zend_Validate_File_ImageSize

Sets the minimum image size

Parameters
NameTypeDescription
$optionsarray

The minimum image dimensions

Returns
TypeDescription
\Zend_Validate_File_ImageSizeProvides a fluent interface
Throws
ExceptionDescription
\Zend_Validate_ExceptionWhen minwidth is greater than maxwidth
\Zend_Validate_ExceptionWhen minheight is greater than maxheight
methodpublicsetImageWidth(array $options) : \Zend_Validate_File_ImageSize

Sets the mimimum and maximum image width

Parameters
NameTypeDescription
$optionsarray

The image width dimensions

Returns
TypeDescription
\Zend_Validate_File_ImageSizeProvides a fluent interface
Documentation was generated by phpDocumentor 2.2.0 .