Hey guys, I've spent weeks trying to find a simple solution to mass uploading photos to be manipulated in various ways, so no one module gave me the freedom I needed for huge amounts of photographs. This may not suit your needs or wants, but we needed to upload potentially 100+ pictures per node and somehow assign them to that specific node. This can obviously be done with Image Attach, and Image Upload, but nothing I found would allow me to upload a directory and walk away. We would spend more time clicking browse, attach, upload, 100 times than anything else and just wasn't worth it. So here's what I did, feel free to ask questions, constructively criticize, improve upon what I tried to do, by all means.
Things needed:
*CCK
*Content Templates
*A little PHP know how
*FTP Access
*If necessary, I used modules like Thickbox, etc
*Image Cache is also useful here
This is the snippet I created through digging in Drupal.org, and various random googling of PHP syntax. Up until a few months ago I've never seen anything outside of C++ and the like, so I was a complete novice when I was trying to pick up PHP entirely by myself. Hence why I don't mind the constructive criticism here, since I'm learning like many of us here.
$id_num = $node->field_idnumber[0]['view'];
$counter = 0;
$filex = file_scan_directory("/home/username/example.com/sites/default/files/" . "$id_num" . "/1", ".*\.[jJ][pP][gG]");
asort($filex);
foreach ( $filex as $filename => $file ) {
if($counter < 1){
print "<a title='' rel='ss1' class='thickbox' href='http://www.example.com/sites/default/files/" . "$id_num" . "/1/" . "$file->basename" . "'>";
$location = "/" . "$id_num" . "/1/" . "$file->basename";
print theme('imagecache', 'slideshow', "$location", 'test');
print "</a>";
$counter += 1;
}
else{
print "<a title='' rel='ss1' class='thickbox' href='http://www.example.com/sites/default/files/" . "$id_num" . "/1/" . "$file->basename" . "'></a>";
$counter += 1;
}
}
Easiest way to explain it is, we name the folder with all the photos that will be FTP'ed to the server the same as the $id_num and with CCK, assign the create content page, a textfield where you can input the number. This is simply the folder name, you don't have to use a number, it's just easiest for us to keep track of things and keep it organized.
$filex scans the directory given via $id_num for all .jpg and .JPG files. The asort ($filex) sorts and puts them in order before they're displayed.
The foreach assigns them all to a thickbox group, and prints the first file in the directory to be displayed with a preset imagecache called 'slideshow'. You may notice theres a . "/1/" . up there as well, that's because we use that snippet 3 times in the node type and within each folder we have 3 subfolders just labeled 1 2 3 to show different sets of photos.
I hope I'm not making this sound more complicated than it really is, cause in the end it turned out to be really simple for us. Here's the site I've been messing with as of lately that uses this snippet. http://www.hotboatweb.com/content/boat/1997-advantage-sr21 I went with genesis + genesis_webify and have been slowly changing it as I pick up more and more CSS etc, so don't pick on me to much, lol.
Hope this sparks an idea or helps someone else out in the Drupal community because I'm usually the one asking all the questions and felt like this is the first post where I may actually have something worth while to share with others and not just heave a plethora of questions on the community.
Take care!
Comments
_
Just out of curiousity-- did you try the webfm module at all? I ask because from what i see this method does not make the files actual node 'attachments' which can be necessary for many file manipulation functions.
Yeah agreed, that's one
Yeah agreed, that's one downside to it right now. I haven't figured out any syntax that would associate those files to the actual node and be referenced in the drupal database somehow, but you'd think there would be a way to add a few lines in the foreach () that would write each file listed to that nid... Could be something to look into, I'll write it down and take a second look, cause it would definitely help me out to have that functionality as well.
EDIT: Since my solution is kind of specific, the only file manipulations taking place for me in this content type is thickbox for display, and imagecache for a thumbnail which can be done without the files being within drupals database.
WebFM? I can't say that I have, how's that work? I suppose I can go find it, is it similar to an FTP ui?
_
Yep--- and once the files have been uploaded you can then choose to create nodes with attachments from them.
I haven't had a chance to
I haven't had a chance to install it yet and see what it's all about, but the only thing I'd need to know really is does it allow bulk/directory uploads?
_
I don't have it loaded anymore-- i used it for the initial migration of content from a static site to drupal. I can't remember if the bulk upload was through the drupal ui or if i simply ftp'd the files to the webfm directory. But it did allow me to grab all those files, bring them into drupal, and attach them to nodes very easily through the webfm ui. Currently I'm using image_fupload for bulk uploads.
Very cool, thanks for all the
Very cool, thanks for all the responses.