Perforce Chronicle 2012.2/486814
API Documentation
|
Extends Zend_Form_Element_File to provide special validation and handling for image files. More...
Public Member Functions | |
getDefaultDisplayDecorators () | |
Get the default display decorators to use when rendering content elements of this type. | |
init () | |
Extend parent to include image validator. | |
populateRecord (P4Cms_Record $record) | |
Overrides the population of file specific metadata in order to include some image specific data. |
Extends Zend_Form_Element_File to provide special validation and handling for image files.
Content_Form_Element_ImageFile::getDefaultDisplayDecorators | ( | ) |
Get the default display decorators to use when rendering content elements of this type.
Reimplemented from Content_Form_Element_File.
{ return array( array( 'decorator' => 'DisplayImage', 'options' => array( 'placement' => Content_Form_Decorator_DisplayImage::REPLACE ) ) ); }
Content_Form_Element_ImageFile::init | ( | ) |
Extend parent to include image validator.
{ parent::init(); $this->addValidator( 'File_Extension', false, "gif, ico, jpg, jpeg, png, svg" ); }
Content_Form_Element_ImageFile::populateRecord | ( | P4Cms_Record $ | record | ) |
Overrides the population of file specific metadata in order to include some image specific data.
P4Cms_Record | $record | the record to populate |
Reimplemented from Content_Form_Element_File.
{ parent::populateRecord($record); if ($this->isUploaded() && ($this->isReplaced() || !$this->hasExistingFile())) { $tempFileName = $this->getFileTempName(); $size = getimagesize($tempFileName); $metadata = $record->getFieldMetadata($this->getName()); $metadata['dimensions'] = array('width' => $size[0], 'height' => $size[1]); $record->setFieldMetadata( $this->getName(), $metadata ); } return $this; }