Great module, appeared just two days before I needed it :) I have a slightly different use case, I needed a download link per node to download all images in a zip file. So I added three functions to do that. It only downloads the originals, and has no settings, but maybe someone will find it useful.

CommentFileSizeAuthor
image-download.patch1.45 KBdrifter

Comments

infojunkie’s picture

Status: Needs review » Closed (won't fix)

Thanks for the patch. I agree that this is a needed piece of functionality, but your solution is too specific as far as I'm concerned. Please take a look at Actions REST for a more generic solution.

sansui’s picture

This looks really awesome - thanks drifter, I'm going to try this out today and see if I can get it working. It's a feature I've been looking for

Looking at the patch, how did you set up your imagefield actions to create the zip? Do you think it would be fairly easy to modify to use with swfupload widget instead of imagefield specifically? (swfupload is bulk image uploader)

sansui’s picture

I was able to modify the code using drifter's patch (had to remove some of the conditions for image module etc, since I'm not using image nodes, just imagefields).

Only problem I've noticed, when not trying to go through the imagecache derivative creation stuff... the zip file comes back with a phantom folder/file in the zip file. So my zip file structure looks like:

sites
-default
--files (this one is a folder)
--files (this one looks like a file with no extension, and can't be extracted)
---jpeg1
---jpeg2
---jpeg3

So in function imagefield_archive_action when the code uses

$file['node'] = $node;
$files[] = (object)$file;

instead of

if (!is_file($derivative['filepath'])) {
if (!imagecache_build_derivative($preset['actions'], file_create_path($file['filepath']), $derivative['filepath'])) continue;
}
$files[] = (object)$derivative;

I end up with the phantom file/folder, which causes issues on extraction. When I set it to use an imagecache preset, I get a php/imagecache error, but there is no more phantom file/folder.

I don't know too much about php zip, but thought I'd see if you had any ideas about this, Drifter

sansui’s picture

Ah, I never followed up on this, but for anyone else with a similar problem it was an easy fix to just remove the call to imagecache_build_derivative.

And to remove the folder structure, simply change this line

$pathname = token_replace_multiple($context['settings']['filename'], array('global' => NULL, 'imagefield_archive' => $file, 'node' => $file->node));

to :

$pathname = $file->filename;

Using drifter's patch as a base and some additional simple modifications, this module has been very useful for packaging up a node's images and providing a link for each.