Xety/Cake3-Upload

2.0 - Rewrite the entire plugin to use the correct callback methods

Opened this issue · 3 comments

Xety commented

There we go.

One of the big problem in this plugin, is that the plugin is using the beforeSave() callback method. And that cause several serious issues like #2.

Because this plugin is using by many people (7.2k download), I don't want to rewrite it only with my idea and don't listen the other people, but i want that all people who are interested by this plugin to participate to the 2.0 by exposing their idea, new features etc and we will try to do the best 2.0 as we can. 😛

The only thing that i want, is to keep all the current features as described here : Cake3-Upload#configuration to not break all the current configuration of the plugin. So the people will be able to update the plugin from the 1.x to the 2.0 without breaking changes.

Now i will expose the new features that i have in my mind :

  • Rezise image on fly using Intervention/image.
    • Use thumbnails model to create multiple images with different sizes. I.e :
      • users/1/avatar_250x250.png
      • users/1/avatar_80x80.png
      • etc
    • Also, check if we can add more customization to the image, like an option to change the background-color etc.
    • All these options must be customizable for each fields (Not a global configuration)
  • Allow multiple upload.
  • Keep the prefix option, but maybe write a Helper for that, and deprecate this option ?
  • Allow remote upload ? Warning, this can be a serious security issue, if it's not handling correctly.
  • Use the afterDelete() callback method to remove images linked to this Entity.
  • Add more complete examples
  • Use https://readthedocs.org for the docs ?

Expose your ideas, comments, what you want to see in the 2.0, what is the best callbacks to use for you etc. 😛

I think another great feature - albeit a potentially complex one - would be to create a files table and controller and save all file information there, and then have other controllers reference back to this table as a hasOne/hasMany association. Then, functionality related to files could be built based around this table and configuration for all places where uploading is used could be centralized. I think in the long run this would make expanding the plugin easier and it would allow for hasMany associations for files.

I'm looking forward to your version 2.0. I share your idea to not change the configuration. I like your mentioned ideas.

For the ":id" feature you can maybe use the afterSave callback. First you save the file to e.g. the "tmp/" folder and in the afterSave callback rename/move the file to the actual folder / file using the id, which is now present.

I would really like:

  • Multiple Upload
  • Save to associated tables (e.g: Hotel hasmany Photos)