Closed (duplicate)
Project:
Image
Version:
6.x-1.x-dev
Component:
image.module
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
1 Mar 2008 at 01:55 UTC
Updated:
9 May 2008 at 18:14 UTC
Jump to comment: Most recent file
Comments
Comment #1
pglatz commentedI have created a patch to allow the use of contributed modules to provide alternative file storage methods.
I have also created an example storage extension module, but am not sure how to submit it. The manual says issue posts can only be patch files. I would appreciate advice on the procedure I need to follow. In the meantime, I will be glad to email my example to anyone who would like a copy. Email phil@glatz.com
I also have an extensive readme on how this feature works. Excerpt:
A solution
----------
Modify the image module to allow specifying an alternate way of creating image
files. This is easy to do, there is a single function _image_filename() used to
create the full path to the image.
Additionally, the image module configuration tool must be modified to allow selecting the file path method to use.
Creating a custom module
I have designed a small plugin API for adding file path extensions. Extensions
are created in the form of a module. More than one can be installed on a server,
but only one will be used at a time. Be careful to create unique function names,
to avoid namespace collisions.
Each extension module requires this function:
hook_imagepath($name, &$errmsg)
Its presence identifies the module as an image file path extension.
Parameters:
$name the name of the file to create the path for
$errmsg pointer to a variable for returning an error message
Returns:
The created path, based on the file name passed to it. It will create any new directories required. If an error occurs, the function will return false, with an error message returned in $errmsg.
The .info file for the module should include the lines:
package = Image dependencies = image
Administration
--------------
The file image.module has been modified in three places to accommodate this new feature:
1) image_admin_settings() now contains a way to select currently installed image
path extension modules. These are displayed for selection via radio buttons,
along with the default image.module flat directory method.
I have added a hook to inicate that the module is an image filepath extension
(hook_imagepath). Any installed and activated module with this hook defined will
appear in the list of available methods.
2) image_settings_sizes_submit() has been modified to store the image path
extension, in the variable image_path_extension.
3) _image_filename() has been modified to determine what the current image path
extension is. This will be either the name of the module containing the
extension, or 'default' to use the default image path.
The file image.install has been modified to delete the variable
image_path_extension when the module is uninstalled.
Example module
--------------
As an example, I have created an extension to create a file path based on a
hashed, multilevel directory hierarchy.
It is named module image_hashdir, and is located in the image/contrib directory.
Plese see the accompanying README.txt for details on installation and usage.
Temporary files
---------------
A temporary file is created when an image is uploaded. These files will continue
to be stored in the temp subdirectory of the default image directory. It is not
necessary to cache temp files, since a large are not likely to be generated
between temp file cache purges (which are done by the image module cron job).
Interaction with Imagecache
---------------------------
The imagecache module uses its own file storage scheme, and is not affected by
this modification.
Installation
------------
The enclosed patch file is based on image-5.x-2.x-dev.tar.gz
Copy image.module to image-orig.module, then apply the patch:
cp image.module image-orig.module
patch -u image-orig.module image.patch
Install and activate the image_hashdir module.
Open the settings page for the image module. Note that under the File paths tab
is a new section, "Filepath extensions." This will create a list of installed
file extensions, as well as the default (flat directory) method.
Comment #2
Hetta commentedOK, the patch applies, and doesn't break things -- but doesn't seem to do anything either.
Perhaps that's because the image_hashdir module you mention isn't included?
Comment #3
pglatz commentedYes - I didn't know how to submit it as a contributed module. Do I need a CVS account for this? In the mean time, I will be glad to email the module to anyone who is interested.
Comment #4
drewish commentedfor this feature to be committed it'd need to be done for 6.x first and then backported.
Comment #5
Hetta commentedJust attach the new module (as .txt) to your next reply in this thread, and add a note that it should end up in the /contrib/ folder of image. I'll be happy to test for 6.x (and 5.x-2.x-dev).
Thanks!
Comment #6
drewish commentedmarked #166979: Hashed directory creation for storing thousands of images on file system as a duplicate since this has a patch.
this'll need to be committed to 6.x and then backported.
Comment #7
8manj-dupe commentedHello
The functionality this addition would bring I think would be a real advantage, whats the latest on the addition to the module, and what can I do to help test and deploy this facility?
Comment #8
Hetta commentedOK, I'm marking this one as duplicate, since it looks like pglatz has abandoned the issue.
Monorob: go to this issue http://drupal.org/node/103793 and test the patch ...
Comment #9
pglatz commentedI haven't abandoned this; sorry for the delay between posts. I have patches for both 5.x-2.x-dev and 6.x-1.x-dev, and will be posting them shortly. I will also be glad to mail them to anyone. Phil