Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. $this->validatorSchema->setPostValidator(
  2. new sfValidatorCallback(array('callback' => array($this, 'checkSize')))
  3. );
  4.  
  5. public function checkSize($validator, $values)
  6. {
  7. if(!isSet($values['logo'])) return $values;
  8. $maxPxSize = sfConfig::get('app_frontHal_maxPxSize');
  9. list($width, $height) = getimagesize($values['logo']->getTempName());
  10. if($width > $maxPxSize || $height > $maxPxSize)
  11. {
  12. throw new sfValidatorErrorSchema($validator, array('logo' => new sfValidatorError($validator, "Max image pixel size : $maxPxSize x $maxPxSize")));
  13. }
  14. return $values;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement