Home > Bez kategorii > Best way to generate thumbnails in Symfony 1.4

Best way to generate thumbnails in Symfony 1.4

add following method to form class

/* lib/form/doctrine/ExampleForm.class.php */
protected function processUploadedFile($field, $filename = null, $values = null) {

   $fn = parent::processUploadedFile($field, $filename, $values);

    if ($fn != "" && $fn != null && $this->getValue($field) != null) {
      if($this->getValue($field)->getTempName() != null){
        $thumb = new sfThumbnail(400, 300);
        $thumb->loadFile(sfConfig::get('sf_upload_dir') . '/image_directory/' . $fn);
        $thumb->save(sfConfig::get('sf_upload_dir') . '/thumb_directory/' . $fn);
      }
    }

    return $fn;
  }

,

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *

*

Możesz użyć następujących tagów oraz atrybutów HTML-a: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks:0

Listed below are links to weblogs that reference
Best way to generate thumbnails in Symfony 1.4 from Dziennik Programisty
TOP