Cakephp MeioUpload removeOrginal

323 views Asked by At

removeOriginal Dont work on MeioUpload !

i have this code in my post model :

/model/post.php

 public $actsAs = array(
            'MeioUpload.MeioUpload' => array(
              'avatar' =>array(
                 'thumbnails' => true ,
                 'thumbsizes' => array('small'  => array('width'=>100, 'height'=>100)),
                 'thumbnailQuality' => 75, 
                 'thumbnailDir' => 'thumb',
                 'removeOriginal' => true 

               )
            )
        );

i want to upload thumbs only , I do not need the source picture .

(cakephp 2.1.2)

thanks

1

There are 1 answers

0
Ella Ryan On

This Behaviour is depreciated and no longer supported (https://github.com/jrbasso/MeioUpload) but I had the same problem and have no need to migrate yet.

For anyone in the same boat as me, you can fix it as follows:

  • Open Model/Behavior/MeioUploadBehavior.php
  • Look for this block of code which appears TWICE:

    // If the file is an image, try to make the thumbnails
    if ((count($options['thumbsizes']) > 0) && count($options['allowedExt']) > 0 && in_array($data[$model->alias][$fieldName]['type'], $this->_imageTypes)) {
        $this->_createThumbnails($model, $data, $fieldName, $saveAs, $ext, $options);
    }
    
  • After the SECOND occurrence insert the following code (which does appear already under the first occurence):

    if ($options['removeOriginal']) {
       $this->_removeOriginal($saveAs);
    }
    

I did this in my project and seems to be working just fine so far!