Development

Changeset 16005

You must first sign up to be able to contribute.

Changeset 16005

Show
Ignore:
Timestamp:
03/04/09 22:55:20 (4 years ago)
Author:
boutell
Message:

Preview cache can accommodate multiple sizes for the same
instance (which sounds nutty, but if you pass a form submission
on to another form or change the size in the form as you
go from your just-uploading-lots-of-files phase to your
mostly-annotating, some-replacing-of-images phase, it'll happen)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/pkPersistentFileUploadPlugin/trunk/lib/widget/pkWidgetFormInputFilePersistent.class.php

    r15978 r16005  
    7070      { 
    7171        // While we're here age off stale previews 
    72         $dir = sfConfig::get('sf_web_dir') . "/uploaded-image-preview"; 
     72        $subdir = sfConfig::get('sf_persistent_upload_preview_dir', "/uploaded-image-preview"); 
     73        $parentdir = sfConfig::get('sf_web_dir'); 
     74        $dir = "$parentdir$subdir"; 
    7375        pkValidatorFilePersistent::removeOldFiles($dir); 
    74         $output = "$dir/$persistid.jpg"; 
     76        $imagePreview = $this->getOption('image-preview'); 
     77        $width = $imagePreview['width'] + 0; 
     78        $height = $imagePreview['height'] + 0; 
     79        $resizeType = $imagePreview['resizeType']; 
     80        if (!in_array($resizeType, array('c', 's'))) 
     81        { 
     82          $resizeType = 'c'; 
     83        } 
     84        $imagename = "$persistid.$width.$height.$resizeType.jpg"; 
     85        $url = "$subdir/$imagename"; 
     86        $output = "$dir/$imagename"; 
    7587        if (!file_exists($output)) 
    7688        { 
    77           $imagePreview = $this->getOption('image-preview'); 
    7889          if ($imagePreview['resizeType'] === 'c') 
    7990          { 
     
    90101            mkdir($dir); 
    91102          } 
    92           $path = "$dir/$persistid.jpg"; 
    93103          pkImageConverter::$method( 
    94104            $info['tmp_name'],  
    95             $path
     105            $output
    96106            $imagePreview['width'], 
    97107            $imagePreview['height']); 
    98108        } 
    99         $result .= "<img src='/uploaded-image-preview/$persistid.jpg' />";  
     109        $result .= "<img src='$url' />";  
    100110      } 
    101111      $result .= $this->getOption('existing-html');