ephotovalidator Uploaded photo validator

  1. Documentation
  2. Change Log

This extension extends CFileValidator, so it has its basic functionality plus we can validate photo's mime type, min height, min width, max height and max width.

Resources

Documentation

Requirements
  • Yii 1.0 or above
Installation
  • Extract the release file under protected/components
Usage

See the following code example:

public function rules()
{
	return array(
		'photo', 'EPhotoValidator', 'maxWidth'=>800, 'maxHeight'=>600, 'minWidth'=>100, 'minHeight'=>100
	);
}
Settings

Another setting not shown above is mimeType which can be plain string with ie: image/jpeg or array of mime types:

public function rules()
{
	return array(
		'photo','EPhotoValidator','mimeType'=>array(
			'image/jpeg','image/gif','image/png'
		));
}
Error Messages

For every setting there can be set an error message accessed by field settingError, like: minWidthError, mimeTypeError, maxHeightError etc:

return array(
		'photo','EPhotoValidator','mimeType'=>array(
			'image/jpeg','image/gif','image/png'
		), 'mimeTypeError'=>'Only common types allowed');

Change Log

May 3, 2009
  • Initial release.
9 1
9 followers
1 428 downloads
Yii Version: 1.1
License: (not set)
Category: Validation
Tags:
Developed by: emix
Created on: May 3, 2009
Last updated: 14 years ago

Downloads

show all