Peter's Blog

Redefining the Impossible

Drupal bulk image import


I had 190 pictures to import into a Drupal based system. I had been avoiding using the image module as it is hard wired to upload one image at a time, give it a title and description etc and the whole thing would take hours.

I had been using Gallery2 till now because of the bulk picture import. Gallery2 is very sophisticated, has many features and is still beta software. I ran an update on my debian server and this managed to break Gallery2: any attempt to access the gallery gave a meaningless error and referred me to the gallery home page. Since the installation is quite complex, a mix of virtual directories, symbolic links and any number of other tricks to hide itself I couldn't be bothered to try to fix it. It is still beta so I'm not surprised it broke and it may well break again. Also it says in the blurb that it had not been through a security review and that did bother me.

I hadn't been impressed with any other gallery software I found so I decided to return to Drupal and the image module, if only because it is an integrated solution. Searching the drupal site, I came across the image_import module which allows what I wanted: bulk import of a directory full of pictures. I only had to install the image_import.module file, it seems I already have the 'walkah' version of the image module that is one of the requirements. I have only installed standard modules so the walkah one may be vanilla drupal 4.6 image module (it does say walkah at the top of the file).

It works as it said on the box, it imported all my files in minutes. It gave titles and descriptions based on the file names, e.g. DSC_123123.jpg but I don't really care about that. It has a nice 'trial run' feature that tests to see if the import is likely to work by checking file existence, permissions etc. It also has a timer facility to stop it from breaking any apache/php security rules that prevent long-running processes. My system limits a php run to 30 seconds so I had to set this time limit to 20 seconds and import my files in two or three chunks. This was not a big problem, the form settings were still filled in I just had to keep pressing the go button.

Two final problems, both with the image module:

  • it would be nice to have 'prev' and 'next' links to walk through the pictures. Can this be rigged with the book module?
  • drupal tries to theme the original images, although they are way too big to fit in the theme and look broken. It really only needs a link to the original jpg file. It is not important to me to show the title and description on the full image, it is mainly there for downloading. I can hack this one in myself.

Filed under: drupal photography

Valerie Says:

Hey. I have an image gallery just using the image module, and I'd really like 'prev' and 'next' buttons as well. Maybe I'll try to hack it in one of these days....

Peter Says:

To fix the 'view original' thing I changed the image_link function in image.module as follows:

if (variable_get('image_view_original', 0)) {
//      $links[] = l(t('view original'), 'node/'.$node->nid, NULL, 'size=_original');
  $links[] = l(t('view original'), file_create_path($node->images['_original']));
}

Peter

Anonymous Says:

Hey, I know it's been two years since this post, but using the image gallery and lightbox2 you are able to have prev/next options through lightbox as it reads the images in a specific gallery, or with same taxonomy.

airtonix Says:

yeah i highly recommend any of the lightbox variety of javascript based image viewers.

prototype and mootols framework have done much to improve the efficenecy of code execution by streamlining the base code required to make things like these work.

Have Your Say

I welcome constructive comments or questions but I reserve the right to delete any comments that displease me.

Who are you?

(Optional) If you enter an email address here I might email you back. Your email address will not be sold to spammers or shown anywhere

What do you have to say?