Hello all,
I have developed this patch for a recent project of ours.
It adds a hook call to _imagecache_cache, which is called if the source file (the original one) does not exist in the file system of the server, and it allows custom modules to try and retrieve the image from some source for imagecache.
For this project, we have stored all of the images in a blob field in the database and give them a unique name then. This is because we have multiple web nodes, and the upload of images should be centralized. So we needed a method to deploy the image files to the different web nodes, and this seemed to be the best method.
All of the image records have a unique path stored in the db. If the imagecache gets called with a path e.g. "/dbimage/
" (I have implemented the hook which takes care of URLS with that dbimage prefix in a different module), and that particular web node hasn't encountered that image before, the hook gets called, and the modules implementing the hook get a chance to retrieve the image (e.g. from the db), and put it into the path imagecache expects the file to be.
The hook function then returns the filename of the retrieved image. If the hook returns null, it signals that it couldn't find an image with that path.
This works remarkably well, we have developing on this base for 3 months and it has been into production for a month. I would love to see this function being integrated into the core imagecache functions, so I don't need to implement it myself every time a new imagecache version comes out.
Regards,
Jens
| Comment | File | Size | Author |
|---|---|---|---|
| imagecache_hook_retrieve_image.patch | 1.3 KB | jenshoffrichter |
Comments
Comment #1
ismytrnt commentedCould you please provide code example how to proper use your patch to retrieve images from the database. Unfortunately all my attempts with imagecache were not successful.
THANK YOU.
Comment #2
fizk commentedPlease reopen if this is still an issue with ImageCache 6.x-2.0-rc1.