Skip to content

Commit

Permalink
Fix the creation of folders for thumbs. Closes jrbasso#20.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Basso committed Nov 24, 2009
1 parent ab0a19a commit c1edbae
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions models/behaviors/meio_upload.php
Expand Up @@ -665,8 +665,6 @@ function _uploadFile(&$model, $data = null) {
// If the file is an image, try to make the thumbnails
if ($options['thumbnails'] && count($options['allowedExt']) > 0 && in_array($data[$model->alias][$fieldName]['type'], $this->_imageTypes)) {
foreach ($options['thumbsizes'] as $key => $value) {
// Create the directory if it doesn't exist
$this->_createThumbnailFolders($options['dir'], $key);
// Generate the name for the thumbnail
$thumbSaveAs = $this->_getThumbnailName($saveAs, $options['dir'], $key, $data[$model->alias][$options['uploadName']], $sub);
$params = array(
Expand Down Expand Up @@ -738,8 +736,6 @@ function _uploadFile(&$model, $data = null) {
// If the file is an image, try to make the thumbnails
if ($options['thumbnails'] && count($options['allowedExt']) > 0 && in_array($data[$model->alias][$fieldName]['type'], $this->_imageTypes)) {
foreach ($options['thumbsizes'] as $key => $value) {
// Create the directory if it doesn't exist
$this->_createThumbnailFolders($options['dir'], $key);
// Generate the name for the thumbnail
if (isset($options['uploadName']) && !empty($options['uploadName'])) {
$thumbSaveAs = $this->_getThumbnailName($saveAs, $options['dir'], $key, $data[$model->alias][$options['uploadName']], $ext);
Expand Down Expand Up @@ -969,17 +965,18 @@ function _splitFilenameAndExt($filename) {
* @author Jose Diaz-Gonzalez
**/
function _getThumbnailName($saveAs, $dir, $key, $fieldToSaveAs, $sub = null) {
$result = '';
if($key == 'normal'){
$result = $saveAs;
if ($key == 'normal') {
// Create the directory if it doesn't exist
$this->_createThumbnailFolders($saveAs, $key);
return $saveAs;
// Otherwise, set the thumb filename to thumb.$key.$filename.$ext
} else {
$result = $dir . DS . 'thumb' . DS . $key . DS . $fieldToSaveAs;
if (isset($sub)) {
$result .= '.' . $sub;
}
}
return $result;
$this->_createThumbnailFolders($dir, $key);
$result = $dir . DS . 'thumb' . DS . $key . DS . $fieldToSaveAs;
if (isset($sub)) {
return $result . '.' . $sub;
}
return '';
}

/**
Expand Down

0 comments on commit c1edbae

Please sign in to comment.