Created
August 5, 2010 10:53
-
-
Save odracci/509551 to your computer and use it in GitHub Desktop.
processUploadedFile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Override processUploadedFile in ObjectForm | |
* Require sfImageTransformPlugin | |
* @see lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine::processUploadedFile() | |
*/ | |
protected function processUploadedFile($field, $filename = null, $values = null) { | |
$filename = parent::processUploadedFile($field, $filename, $values); | |
if ($filename != "" && $values[$field]) { | |
$method = 'scale'; | |
$thumbImage = new sfImage(sprintf('%s/%s/%s', sfConfig::get('sf_upload_dir'), sfConfig::get('app_upload_image_path', 'images'), $filename)); | |
$thumbImage->thumbnail(50, 50, $method); | |
$thumbImage->setQuality(100); | |
$thumbImage->saveAs(sprintf('%s/%s/%s', sfConfig::get('sf_upload_dir'), sfConfig::get('app_upload_image_path', 'images'), $filename)); | |
} | |
return $filename; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment