Closed designvoid closed 11 years ago
I seem to have done it but using these settings:
public $actsAs = array(
'Uploader.Attachment' => array(
'image' => array(
'overwrite' => true,
'uploadDir' => UPLOAD_DIR,
'transforms' => array(
'imageSmall' => array(
'nameCallback' => 'transformNameCallback',
'method' => 'resize',
'append' => '',
'width' => 800,
'aspect' => true,
'mode' => 'width',
'uploadDir' => UPLOAD_THUMB_DIR,
)
)
)
),
'Uploader.FileValidation' => array(
'image' => array(
'maxWidth' => 2000,
'maxHeight' => 2000,
'extension' => array('gif', 'jpg', 'png', 'jpeg'),
'type' => 'image',
'filesize' => 5242880,
'required' => false
)
)
);
public function transformNameCallback($name, $file) {
return $this->getUploadedFile()->name();
}
Which means I can then just use the filename from the DB and just specify the alternate folder...
Is this correct way of doing things?
Transforms need to be stored in their own column in the database. So in your case, you would have image
and imageSmall
columns.
Yup - changed it to a hasMany and added the columns and it all works like a charm! Many thanks!
Ok so I have got images uploading AOK and versions being created but... How do I get the filenames of the different sizes? ie how would I go about displaying the small version of the upload as all I have in the record is the original filename? Cheers!