You can use self to apply the transformation in the original file withou create a new one
App::uses('AttachmentBehavior', 'Uploader.Model/Behavior');
// In the model
public $actsAs = array(
'Uploader.Attachment' => array(
'image' => array(
'overwrite' => true,
'transforms' => array(
'imageSmall' => array(
'class' => 'crop',
'append' => '-small',
'overwrite' => true
'self' => false,
'width' => 100,
'height' => 100
),
'imageMedium' => array(
'class' => 'resize',
'append' => '-medium',
'width' => 800,
'height' => 600,
'aspect' => false
)
)
)
)
);
Em sábado, 4 de maio de 2013 02h48min50s UTC-3, James Lukensow escreveu:
Anyone figure out how to delete files that are placed in unique folders?Here's my beforeTransform and beforeUpload:public function beforeTransform( $options ) {$options['finalPath'] = 'files/uploads/' . CakeSession::read( 'Auth.User.id' ) . '/';$options['uploadDir'] = WWW_ROOT . $options['finalPath'];return $options;}public function beforeUpload( $options ) {$options['finalPath'] = 'files/uploads/' . CakeSession::read( 'Auth.User.id' ) . '/';$options['uploadDir'] = WWW_ROOT . $options['finalPath'];return $options;}As you can see, I'm placing all my files under /files/uploads/ <!-- User ID Folder--> /test.jpgNow, if I upload my files and just place them under /files/uploads, then delete them, the files are physically removed from the server. It's just when they're placed in a sub folder from the above methods, that it won't physically remove them. Also, when this happens (the files not being deleted), the row is removed from the DB.Secondly, is there anyway when uploading files, to only keep the transformed files? I'd like to just keep a medium and small photo, and remove the other. I'm guessing I could do an after save, and possibly execute the following? $this->Image->deleteFiles ($id, array('medium')); Though, how would I delete the original only?
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment