Oct 04 2008

MeioUpload Behavior – An improved File Upload Behavior for CakePHP

vbmendes @ 12:21

MeioUpload Behavior is an improved File Upload Behavior for the CakePHP framework. It’s based on the Digital Spaghetti’s Upload Behavior.

Juan Basso created a project hosted at github. I am unable to keep working on this behavior an he is making some updates to the code. I think github is a great tool because you can simply fork the project and make your own changes. Go check his work: http://github.com/jrbasso/MeioUpload/tree/master

Download

MeioUploadBehavior version 1.0.1

Related Articles

Features

  • Can be used for any kind of files;
  • Accepts custom directory for files to be uploaded;
  • Validates the file extension and mime-type due to the behavior configuration;
  • Validates the max file size;
  • Allow custom validation rules;
  • Allow as many thumbnails formats as you want;
  • Allow more then one field to be uploadable, with custom options per field;
  • Stores the directory, filesize, and mime-type in the database if the table has these fields. Also allows to customize these fields names;
  • Allow the use of default files and deleting files without deleting the entire record;
  • Delete files when the record is deleted or updated with a new file;
  • Also works in the $model->saveAll method.

Usage

  1. Place the meio_upload.php file in your app/models/behaviors folder;
  2. If you want to use thumbnails, download Nate’s phpThumb Component and place it in your app/controllers/components folder;
  3. Insert in your model table a character varying field:
    CREATE TABLE `products` (
    `id` int(8) unsigned NOT NULL auto_increment,
    `name` varchar(255) default NULL,
    `description` text default NULL,
    `price` double default NULL,
    `picture` varchar(255) default NULL,
    `dir` varchar(255) default NULL,
    `mimetype` varchar(255) NULL,
    `filesize` int(11) unsigned default NULL,
    `created` datetime default NULL,
    `modified` datetime default NULL,
    PRIMARY KEY  (`id`) ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
    
  4. Add the MeioUpload in the $actsAs of your model:
    var $actsAs = array(
        'MeioUpload' => array(
            'picture' => array(
                'dir' => 'img{DS}{model}{DS}{field}',
                'create_directory' => true,
                'allowed_mime' => array('image/jpeg', 'image/pjpeg', 'image/png'),
                'allowed_ext' => array('.jpg', '.jpeg', '.png'),
                'thumbsizes' => array(
                    'normal' => array('width'=>200, 'height'=>200),
                ),
                'default' => 'default.jpg',
            )
        )
    );
    
  5. Use a form file input to the field:
    echo $form->input('picture', array('type' => 'file'));
    
  6. Make sure your form has multipart/form-data enctype:
    echo $form->create('Product',array('type' => 'file'));
    
  7. Make sure the PHP has permission to write in the folder yous specified and the php.ini allow the MAX_FILE_SIZE you specified.

Options

When you apply the MeioUpload Behavior to a Model, you pass an array with your options. Here are the options you can change and it’s defaults.

  1. dir

    The folder where the uploaded files will be saved. It must be inside the app/webroot directory and defaults to an empty string, what means that it will be the app/webroot itself. If you specify some path, then it will be app/webroot/the_path_you/specified. In this option you may use the {DS} pattern, what will be converted to ‘/’ in UNIX systems and to ‘\’ in Windows systems.
  2. allowed_mime

    This option specifies the allowed mime-types for the files. It defaults to an empty array. What means that every mime-type will be accepted. But if you specify an array with the mime-types allowed, only files of these mime-types will be accepted.
    var $actsAs = array(
        'picture' => array(
            'allowed_mime' => array('image/jpeg', 'image/pjpeg', 'image/png')
        )
    );
    
    The code above says that the picture field will be a file uploaded, and it allows ‘image/jpeg’, ‘image/pjpeg’ and ‘image/png’ mime-types.
  3. allowed_ext

    This option specifies the allowed file extensions. It defaults to an empty array. What means that every extension will be accepted. But if you specify an array with the extensions allowed, only files with these extensions will be accepted.
    var $actsAs = array(
        'picture' => array(
            'allowed_ext' => array('.jpg', '.jpeg', '.png')
        )
    );
    
    The code above says that the picture field will be a file uploaded, and it allows ‘.jpg’, ‘.jpeg’ and ‘.png’ extensions.
  4. create_directory

    If you want to create the directory specified in the dir option if it don’t exists, then set this option to true. It already defaults to true, but you can set it to false.
  5. max_size

    The max file size allowed in the upload. Be sure it’s lower then the php.ini configuration. You can set a numeric value of bytes, or set it in other unit like ’8 Kb’, only ‘kb’, ‘mb’, ‘gb’ and ‘tb’ units are allowed and it’s not case-sensitive. It defaults to 2 Mb.
    var $actsAs = array(
        'picture' => array(
            'max_size' => '4 Mb'
        )
    );
    
  6. default

    If you have a file that you want to use if the field is left blank, like a default picture for users who don’t have one, set this option to the name of this file. Make sure it is inside the folder specified in the ‘dir’ option.
    var $actsAs = array(
        'picture' => array(
            'default' => 'default.jpg'
        )
    );
    
  7. fields

    With this option you can customize the field inside your model table, where the data will be saved. The filename is the key of the options array, and you can setup fields to store the filesize, mime-type and directory. It defaults to ‘filesize’, ‘mimetype’ and ‘dir’ respectively, but you can customize with an array:
    var $actsAs = array(
        'picture' => array(
            'fields' => array(
                'filesize' => 'picture_filesize',
                'mimetype' => '{field}_mimetype',
                'dir' => 'pictures_folder'
            )
        )
    );
    
    The code above says that your filesize, mimetype and dir fields will be ‘picture_filesize’, ‘picture_mimetype’ and ‘picture_folder’ respectively. And the filename field will be pictures. You may notice that in mimetype case, i used the constant {field} that will be replaced with the field name(picture in this case).

Validations

The behavior automatically include some validations to your field. Here they are:

  1. FieldName Checks if the field has been setup to be and uploadable.
  2. Dir Checks if the directory exists or if it can be created. This validation depends on the option ‘create_directory’.
  3. Empty Checks if the filename is not empty. It defaults to be used only on create.
  4. UploadError Checks if ocurred erros in the upload.
  5. MaxSize Checks if the file isn’t bigger then the max file size option.
  6. InvalidMime Checks if the file is of an allowed mime-type.
  7. InvalidExt Checks if the file has an allowed extension.

You can overwrite any of the parameters of these default validation rules. Directly in the model $validate var:

var $validate = array(
    'picture' => array(
        'Empty' => array(
            'check' => false
        ),
        'InvalidExt => array(
            'message' => 'This file extension isn't allowed.'
        )
    )
);
In the code above, i changed the message for the ‘InvalidExt’ default validation. You can also disable any of the default validations by setting the ‘check’ atribute fo false as is shown in the example above for the ‘Empty’ default validation. You can change any of the other parameters of the built-in cake validation:
var $validate = array(
    'picture' => array(
        'Empty' => array(
            'rule' => array('YourDefaultValidation'),
            'on' => 'update',
            'required' => true
        ),
    )
);
You can also change the validation rule for one you have created. But use this functionality carefully.

Setting up file removing

If you send a form data with as field named data[Model][field][remove] not empty, then the behavior will automatically delete the file associated with the record and set it’s value to the default, if it is set, or to empty. To achieve this you can add a checkbox to your form:

echo $form->input('Product.picture.remove', array('type' => 'checkbox'));

155 Responses to “MeioUpload Behavior – An improved File Upload Behavior for CakePHP”

  1. Skeptic says:

    Yeah, I’d say overall nice secure work, however, if every table that had a user uploaded image had a table structure like this one, you’d have yourself some very unnormalized data. Files should be stored in a centralized table. Thanks for your work.

  2. ilcaduceo says:

    @Sparkybarkalot @sutehi @Sytze Loor and anyone else who gets an array field problem. The name of file that contain behaviour must be meio_upload.php instead MeioUpload.php… I fix this and it was fine! Bye!

  3. bendo01 says:

    dear Vinícius Mendes, thank you for this upload behavior, for the past mistakes i’ve done is forgot to add this line echo $form->create(‘Product’,array(‘type’ => ‘file’));

    thanx you so much for this amazing behavior :) you are the best :)

  4. bendo01 says:

    ohh yeah i forgot to ask, is there an example for multiple upload ? please i need a guide/ example :)

  5. Vinicius Mendes says:

    Dear bendo01. Good that you liked the behavior.

    Since I stopped working with CakePHP, I don’t work with MeioUpload anymore. But some people created a project hosted at github to keep mantaining it. The link to the project is in the start of this post.

  6. Sebas says:

    Hello!! thank you very much!!

    I only see a detail about the extension(like JPG), y left a patch.

    Index: app/models/behaviors/meio_upload.php

    — app/models/behaviors/meio_upload.php (revisão X) +++ app/models/behaviors/meio_upload.php (cópia de trabalho) @@ -720,12 +720,12 @@ App::import(‘Component’, ‘Thumb’); $system = explode(“.”, $name);

    • if (preg_match(“/jpg|jpeg/”, $system[1]))
    • if (preg_match("/jpg|jpeg/i", $system[1]))
      {
          $src_img = imagecreatefromjpeg($name);
      }
      
    • if (preg_match("/png/", $system[1]))
      
    • if (preg_match(“/png/i”, $system[1])) { $src_img = imagecreatefrompng($name); }
  7. Sebas says:

    Index: app/models/behaviors/meio_upload.php

    --- app/models/behaviors/meio_upload.php (revisão X) +++ app/models/behaviors/meio_upload.php (cópia de trabalho) @@ -720,12 +720,12 @@ App::import('Component', 'Thumb'); $system = explode(".", $name);

    • if (preg_match("/jpg|jpeg/", $system[1]))
    • if (preg_match("/jpg|jpeg/i", $system[1]))
      {
          $src_img = imagecreatefromjpeg($name);
      }
      
    • if (preg_match("/png/", $system[1]))
      
    • if (preg_match("/png/i", $system[1])) { $src_img = imagecreatefrompng($name); }
  8. CakePHP Tutorial: Videos zu einem Model hinzufügen at Manuel Boy Coder Blog says:

    [...] den Upload der Video-Datei verwenden wir das absolut geniale Meio-Upload-Behavior. Die Dokumentation auf der Projekt-Seite ist schon sehr aussagekräftig, zur Sicherheit werde ich [...]

  9. Marcelo says:

    Olá, gostaria de parabenizalo pelo plugin, ficou muito bom realmente.

    Mas encontrei um problema e não consegui resolver, qdo configuro o thumb ele retorna esse erro:

    Notice (8): Uninitialized string offset: 0 [APP/vendors/phpThumb/phpthumb.class.php, line 527] Notice (8): Uninitialized string offset: 1 [APP/vendors/phpThumb/phpthumb.class.php, line 527]

    A configuração:

    ‘thumbsizes’ => array( ‘normal’ => array(‘width’=>343, ‘height’=>343), ‘small’ => array(‘width’=>37, ‘height’=>37), ‘medium’ => array(‘width’=>74, ‘height’=>74), ‘large’ => array(‘width’=>110, ‘height’=>110), )

    Obrigado.

  10. saints says:

    Why this SQL error? INSERT INTO images (filename, modified, created) VALUES (Array, ’2010-01-25 21:52:29′, ’2010-01-25 21:52:29′)

    ImagesController: var $actsAs = array (‘MeioUpload’ => array( ‘filename’ => array( ‘dir’ => ‘files/images’, )) ); function add() { $this->Image->save($this->data); }

    add.ctp: create(‘Image’,array(‘type’ => ‘file’)); echo $form->file(‘filename’, array(‘type’ => ‘file’)); echo $form->end();?>

    Thank you!

  11. cédric says:

    I have the same SQL error

    add.ctp echo $form->create(‘Image’,array(‘type’ => ‘file’)); echo $form->input(‘picture’, array(‘type’ => ‘file’)); echo $form->end(‘Sauver les informations’);

    ImagesController if (!empty($this->data)) { if ($this->Image->save($this->data)) { $this->flash(‘Your image has been saved.’,'/images’);}}}

    Any idea? I’m stuck.. thanks

  12. cédric says:

    Ok, I’m a newbie in cake. Correct me if I’m wrong, cake’s conventions are the followings:

    class MeioUpload => file meio_upload.php

    In the downloaded archive, there is an upload.php file, that needs to be renamed meio_upload.php to work correctly.

  13. Bernd says:

    Hey folks, thanks a lot for the work you’ve done so far.

    I have a little problem with the use of multiple files. Uploading is no problem, but if I want to delete one of the uploaded files, this is not really possible.

    So lets say I’m using the following form to upload my files:

    echo $form->input(‘Mediafile.0.filename’, array(‘type’ => ‘file’));

    Why is it not possible to delete the file in the following way?

    echo $form->input(‘Mediafile.0.filename.remove’, array(‘type’ => ‘checkbox’));

    Thanks for your help.

  14. jmerrow says:

    Response to comment 125 from Bernd-

    I have the same issue. I notice that if the upload field for the picture you want to delete is populated (i.e. if you’ve chosen another file to upload) it does delete the picture- almost. the value in the db is set to “0.”. If I get this sorted I’ll post here.

    Anyone else solved this?

  15. John says:

    greetings,

    thanks for the excellent behavior.

    we can change the uploads folder to which it is situated outside the webroot?

    good day.

    PS: Sorry about my English. :)

  16. Gennadiy says:

    Trying to get it to work but I am getting this error: Fatal error: Call to undefined function imagecreatefromjpeg() in C:\Apache2.2\htdocs\app\models\behaviors\meio_upload.php on line 725

    I did download and installed phpThumb , dont know if it is related…

    Any suggestions?

    Thanks

  17. Pablo says:

    Hello.

    I want to upload files in different directories depending on the type. For example, images in img, pdf and doc files in docs, etc.

    Is it possible to change the directory as the file is loaded? Or is it possible to define the directory from an input?

    Thank you very much

  18. Lyubomir Petrov says:

    Weird.. if i use default=>”filename.jpg”, i got error, that the default option must contain filename + ext. At the source code (meio_upload.php) at line 226, i see: if (strpos($options['default'], ‘.’) !== false) { trigger_error(__d(‘meio_upload’, ‘MeioUploadBehavior Error: The default option must be the filename with extension.’, true), E_USER_ERROR); }

    Is this a typo ? I guess it must be: if (strpos($options['default'], ‘.’) === false) {

  19. Benny L.E.P says:

    is this behavior compatible with cake 1.3

  20. Fabian says:

    The MeioUpload works perfectlly!! but i want to know how can I show the current image in my View. I try with this code but doesn’t happend:

    data['Perfil']['picture'])): ?> Imagen actual: <img src="data['Perfil']['dir'] . $this->data['Perfil']['picture']; ?>” alt=”Imagen actual” width=”100″ />

  21. Sefac says:

    Is there some way to create squared thumbnails?

    BTW, great behaviour! thanks for all your work.

  22. Sefac says:

    OK, nevermind… for those who need it

    in the model set the thumbnail size and zoomcrop true like this:

    ‘small’ => array(‘width’=>80, ‘height’=>80, ‘zoomCrop’=>true),

  23. Connie says:

    I keep getting an SQL error 1054: Unknown column ‘Array’ in ‘field list’ when I simply duplicated the code for another model, and changed the field name from image to something else, but it doesn’t work. Does the field name always have to be ‘image’?? I can’t use it for multiple models?

  24. OldWest says:

    Hello,

    No matter what I do, I continue to get the “Extension not valid” error ( I changed it to English )..

    I’ve checked all of my extensions. Tried various types of files. But continue to get this same exact error.

    I read through the above posts and it appears some other users where having similar trouble.

    Any ideas? SOS.

  25. Ryan says:

    OldWest, if you are using a flash or java uploader, chances are it is sending files as application/octet-stream as opposed to it’s actual file type. Adding application/octet-stream to your allowed mime types will fix the issue. If you’re generating thumbnails, you’ll need to add it to the behavior’s $_imageTypes array as well. Hope this helps.

  26. LarryTX says:

    I’ve implemented the process described in “Setting up file removing,” and it works great. Just one problem: It defaults to having the checkbox checked. That’s kind of dangerous. Is there anyway to make the default unchecked?

  27. Marco says:

    hi, I have a problem using meioupload. If I use it with the ACL component I get this error uploading a file: Undefined index: User [APP/models/behaviors/meio_upload.php, line 550]

    Any ideas?

    Tnx a lots

  28. lfm says:

    Hi,

    I have a strange problem with meioupload.

    I have three models

    Parent, Child1 and Child2

    In models Child1 and Child2 I use meio_uploads.

    Parent hasMany Child1 and hasMany Child2. (dependent => true)

    The problem occure when I want to remove Parent. MeioUpload remove only files from the file system which are connecteed with model Child1, but files form model Child2 are still on the disc.

    What can be the problem?

  29. Alonso says:

    I need to upload multiple files but i can not find a solution..

    help me help me…

  30. آپلود با cakephp | PHPDevelopers.ir says:

    [...] ریم سراغ آپلود عکس با یکی از این رفتارکننده ها به نام MeioUpload. این رفتار کننده به ما این اجازه رو می ده که به راحتی [...]

  31. Sean says:

    Hi, nice script it generally works very well, however it keeps returning an error when I sumbit the form with no attached image. Ie. [filename] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 )

    In my validation rules I’ve set ‘filename’ => array( ‘allowEmpty’ => true, ‘Empty’ => array( ‘check’ => false, ‘required’ => false )

    But it doesn’t seem to work. Any ideas? Any help much appreciated. All I’d like to do is submit the form with the image upload part as optional.

  32. Gregor says:

    Thank you very much for the nice script. I’ve got one problem: The edit-function send me the error-message: Extensão de arquivo inválida. What does it mean?

  33. Tee says:

    Hi,

    I’m integrating MeioUpload with CakePhp. It works great but I’m having issue trying to upload wmv file. Can you give me direction?

    This is the setting that I have ‘allowedMime’ => array(‘video/x-flv’,'video/mp4′,’video/quicktime’,'video/x-ms-wmv’), ‘allowedExt’ => array(‘.mp4′,’.flv’,’.mov’,’.wmv’)

    So all other extensions work but not wmv.

    Thank you, Tee

  34. Stephen Cagey says:

    The skin’s surface is disrupted, cell division occurs which stimulates fibroblast activity leading to collagen manufacturing. Human pores and skin sloughs off at a slower rate with age, so proponents with the approach claim the exfoliation of various layers of the stratum corneum can lead to normally more youthful appearing skin.

  35. asdzxc says:

    For those people who are asking about SQL error:1054 Column unknown ‘Array’ , i got some simple solution, im really pissed with all of the people who ignored to answer this question and yet knows the idea why its happening, you didnt even bother sharing it, i Hope nobody will do that to you. To Vincous, you didnt even bother replying at them!!! how cruel, you could just say that you dont know the answer DONE!! dont let people hanging! or maybe its just because of your pride? . . . For the solution, the main reason why the error is displayed, is simply because cake is unable to access the Behavior, if you debug it, debug($this->data) and you see the [name], [type] etc.. that is correct, the data is not just handled by the behavior, in my case the problem was a TypeO, my $actAs was missing with ‘s’ so its supposed to be $actsAs, im not sure how this happened, but i used the Meio before and it was successful, i even copy-paste may previous work, so i dont know how did that happened. I hope this help, and for the people that im talking about and for the moderator, think about it. It’s better to tell the truth that you dont know the answer than let people hanging with there questions. Regards, and thank you for the beautiful piece of code.

  36. vbmendes says:

    @asdzxc In the beginning of the post, I am telling that I am unable to keep working on this code. I no longer work with Cake PHP and Juan Basso is mantaining the project. This is why I don’t replay to questions here. If you have any issue, please use the github project: https://github.com/jrbasso/MeioUpload

  37. asdzxc says:

    @vbmendes, yes i understand that, thanks anyway for creating such piece of code, i hope you would return back here because the idea was great, cheers and thanks again :)

  38. truky says:

    Hello, first thanks for this behavior … Why this error if i have ‘create_directory’ => true

    Fatal error: Call to undefined method Folder::mkdir() in …on line 370

    with the directory created and put that option a false .. no problem …works perfectly

    I’m using cake 1.3

  39. m16u says:

    hi, i have a problem .. i dont want to use the check to remove my image field in the table.

    i have a function to update this field to blank

    $data = array( ‘Node’ => array( ‘id’=>$id, ‘imagen’=>” ) ); $this->Node->save( $data, false, array(‘imagen’) );

    and with this function i can’t modify the table. it works with other fields but image field doesnot work

  40. jerome says:

    very nice tutorial and it works great. but i have a little question. is it possible to create the galery_name as folder to.

    so when i upload an image and select the Galery “Example”, the folder “Example” doesn´t exists, the model creates the directory ? nice grretings

  41. jerome says:

    Hi,

    how can i use the watermark function from phpThumb. Anybody an idea ? :-)

    nice greetings

  42. 4life says:

    You could certainly see your skills within the work you write. The arena hopes for even more passionate writers like you who are not afraid to mention how they believe. At all times go after your heart.

  43. Juan Pablo says:

    Hello,

    I can not make it work… :(

    I can create folders and upload files with PHP by using very simple code. So it should not be a problem with permision.

    Meio is being executed, it does not give any error, and it saves a temporal file… but finaly I could not find the uploaded file at any folder.

    If I put a “debug( $this->data );” at “update()” function in “speeches_controller.php” I have this (it seems to be right):

    Array ( [Speech] => Array ( [filename] => Array ( [name] => usuarios_6.png [type] => image/x-png [tmp_name] => C:\xampp\tmp\php109.tmp [error] => 0 [size] => 90413 )

        )
    

    )

    Any idea?

  44. Rtransat says:

    Hi,

    Sorry for my english, I am french.

    The plugin is really good but phpThumb don’t create thumbnails :(

    My code :

    public $actsAs = array( ‘MeioUpload.MeioUpload’ => array( ‘image’ => array( ‘thumbnails’ => true, ‘thumbsizes’ => array( ‘normal’ => array(‘width’=>200, ‘height’=>200), ), ‘default’ => ‘default.jpg’ ) ) );

    I use version 2.0.4 of cakephp and last version in phpThumb phpThumb is in app/Vendor/phpThumb/

    And also, how to manage two files on the same form in database to store directory, mimetype, size of the two files on the same tables ?

  45. CakePHP 2 : composant d’upload de fichiers images » Le blog de Nicolas Hachet says:

    [...] Pour ce premier article de 2012, je vous propose un code qui peut s’avérer très pratique pour la gestion de vos uploads de fichiers images. Ce composant CakePHP 2.0 prend forme en tant que Behaviour (helpeur de modèle). Le code est basé sur la version 1.0.1 du MeioUploadBehavior. Vous trouverez toutes les infos utiles sur le site MeioUpload Behavior. [...]

  46. armand says:

    The file dose not work in cakephp 2.0. You need to change the uses(‘file’) with App::uses(‘File’,'Utility’). Also there is a call to a method mkdir in folder class wich also is obsolete. the $this->Folder->mkdir($options['dir']) should be replaced with (new Folder($options['dir'], true, 0777)). Also the example in the file itself for creating the database and $actAs variable wont work. Dont bother with them just use the ones on this page. Also this example on this page wont work either on cakephp 2.x.x if yuo dont change echo $form->input(‘picture’, array(‘type’ => ‘file’)); with echo $this->Form->input(‘picture’, array(‘type’ => ‘file’)); and the create form ofcourse. If you make those changes will fave the surprize that still the code dont work in all cases. With a file named aaa.jpg will work. With one named AAA.JPG wont work. It dosent behave well with capital letter extensions.

  47. armand says:

    In order for behaviour to work with both aaa.jpg and AAA.JPG (wich is not the default case) you need to do the following changes in the behaviour code. In the function uploadCheckInvalidExt(&$model, $data) change substr($field['name'],-strlen($extension)) == $extension with strtolower(substr($field['name'],-strlen($extension))) == strtolower($extension). This will ensure that both .jpg and .JPG extension will be recognized but the code still dosent work as expected. You will need to make one more change in function splitFilenameAndExt($filename){ replace the followig code return array($filename,$ext); with the new one $filename = strtolower($filename); $ext = strtolower($ext); return array($filename,$ext); The code will work now. For compliance you may change the var declaration with public even the code will work without doing that change it is better you to do it. Also this behavior is a good for trivial purposes. I have a site with 3 million pictures gathered in few months. Saving them in the same directory will lead to serious performance loss, bootleneck, not to mention you will not be able never ever to open a directory with that many files in it. I come up with a simple solution to save the file in multiple directories.

  48. armand says:

    Also the behavior destroy the picture quality if you don’t put the largest thumbnail first.

  49. armand says:

    But that ony if you use ‘normal’ => array(‘width’=>200, ‘height’=>200). Don’t use normal, use anything else and the behavior will save the original file and the other thumbnails. For example ‘thumbsizes’ => array( ‘small’ => array(‘width’=>100, ‘height’=>100), ‘medium’ => array(‘width’=>220, ‘height’=>220), ‘large’ => array(‘width’=>800, ‘height’=>600) ) Will result in 4 files one is the original and the other 3 are thumb.small, thumb.medium, thumb.large. The normal thumbsize will make the original at normal dimension and resize all the other thumsizes from there. So if you make a normal 100x100px and then want a large 800×600 px the image will be a very poor quality upscale from 100×100 px to 800x800px even the original file may be 8Megapixel or more. So dont use normal at all or at list give it a dimmenson a little bigger that the one you are sure will ever use.

  50. Vinicius Mendes says:

    Dear Armand,

    I don’t maintain this code anymore. There’s a project in GitHub where it’s maintained by other people. I’ve put a disclaimer in the top of the page with this message and the link for the current project. Probably, many of these issues are already fixed there.

    Thanks. Vinicius Mendes

Leave a Reply