Skip to content

Instantly share code, notes, and snippets.

@odracci
Created August 5, 2010 10:53
Show Gist options
  • Save odracci/509551 to your computer and use it in GitHub Desktop.
Save odracci/509551 to your computer and use it in GitHub Desktop.
processUploadedFile
<?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