Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Automatic adding of image versions #9

Closed
bfncs opened this issue Aug 28, 2012 · 5 comments
Closed

Automatic adding of image versions #9

bfncs opened this issue Aug 28, 2012 · 5 comments

Comments

@bfncs
Copy link
Contributor

bfncs commented Aug 28, 2012

When using the image model with versioning, currently all versions are created after uploading. Since it is some standard problem that you get aware of other image sizes you want later, it would be very nice if the Image Model hat a function that checks all images on whether all configured image sizes are there and if not creates the missing ones.

I understand the considerations about why it is a bad idea to create the images in the desired size on the first request, even with caching turned on. I also like the way this is executed here with hashing and everything. But it would be nice to have an automatic way to add new image sizes without having to write your own script for this.

@burzum
Copy link
Owner

burzum commented Aug 28, 2012

There is a start of a shell around for that as far is I remember. Need to check my code / branches. I need that feature too but haven't had the time yet to work on it, my Cart plugin has my primary attention.

The idea is to have something like "cake FileStorage.image generate Model.imgConfigAlias" and "cake FileStorage.image delete Model.imgConfigAlias". If you need it urgently you're welcome to contribute. :)

I do not think you want to trigger this processing from a web page, depending on the amount and size of the images it might take a lot of time and there is a good amount of possible errors (memory, disk space) that can happen. A shell is the better place to do this batch processing if you introduced new formats.

@bfncs
Copy link
Contributor Author

bfncs commented Aug 28, 2012

This was what exactly what I expected ;-)
I will definitely try to work on this, when I get the time but I also have other projects going that can't wait any longer (always the same).

I really like the idea of using the Cake Shell for this while I'd also appreciate a way to start it from withing a web page, to make it possible to use this with shared hosting.

@burzum
Copy link
Owner

burzum commented Aug 28, 2012

An issue with this is that it must be easy to extend and flexible. Because the shell must be always be able to find the correct path for the used adapter. For example if you use S3 you need to check the file in the bucket, download the original, resize it locally, delete the original upload the new version, delete the local copy of it.

So basically each adapter / app specific code might use another way to store the images and build the key / path to them.

I think I'm going to provide a way for the standard config that comes with the plugin and uses the local filesystem but will make it flexible so that you can configure it or use params to make it work with other configurations too.

@burzum
Copy link
Owner

burzum commented Sep 1, 2012

I've pushed a branch that contains a shell to generate and remove image versions. It's still work in progress but worked in a local test for me. I'm also refactoring the Image model to use events to get rid off the weird callback methods it was using before and by this the need to extend the model to change its behavior.

I'm not going to create a controller with a reload-loop, I leave this up to you, but this should be an easy task, just look at the shell and do what it does in a controller with a redirect loop or something else.

@burzum
Copy link
Owner

burzum commented Sep 10, 2012

This is now done in the develop branch.

There is the ImageVersion shell that will do this task.

For the controller check the shell as I suggested and transfer that to a redirect loop or better into a loop using js on the client side that will do an ajax call per image for the conversion, you'll then also be able to track the progress.

@burzum burzum closed this as completed Sep 10, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants