Thursday, July 18, 2013

Mile Johnson Uploader Question

I have the plugin working and it's very great.

 

Only question I have is currently I am trying to upload an image and scale that image to a fixed width, and create a thumb.

That’s all good.

But the original image also gets uploaded and untouched.

So I only need the 2 images created from the uploaded, but end up with 3.

 

Scale the uploaded image to a fixed with and create a thumb from that.

 

Code snip below creates the scaled 750px width, the 100x75 thumb and the untouched image.

 

Just not sure how to modify the uploaded image when looking at the documentation. Or delete it after upload since I do not need the original uploaded file.
http://milesj.me/code/cakephp/uploader

 

public $actsAs = array(

            'Uploader.Attachment' => array(

                        'image' => array(

                                    'name' => 'formatFilename', 

                                    'uploadDir'      => 'img/uploads/',                             

                                    //'dbColumn'   => 'image',     

                                    'maxNameLength'      => 30,                         

                                    'overwrite'      => true,                      

                                    'stopSave'        => true,                      

                                    'allowEmpty' => false,                       

                                    'transforms'    => array(

                                                'scale' =>array(

                                                            'method' => 'resize',

                                                            'width' => 750, 

                                                            //'height' => 75,

                                                            'aspect' => true,

                                                            'mode' => 'width',

                                                            'self' => true,

                                                            'dbColumn' => 'image'),

                                                'thumb' =>array(

                                                            'method' => 'crop',

                                                            'width' => 100, 

                                                            'height' => 75,

                                                            'aspect' => true,

                                                            'mode' => 'width',

                                                            'self' => true,

                                                            'dbColumn' => 'thumb')

                                    )                      

                        )          

            )

);

 

Any help would be great.

Thanks,

 

Dave

 

No comments: