This is my goal.

Has it been done?

Any Suggestions, Comments, Smart Remarks?

Comments

vordude’s picture

Bump.

jplichta’s picture

I have a client that is using the CCK Image Field along with Image Cache to attach images to their nodes.

If there is not a module out there that already does this (http://drupal.org/project/node_import looks like it comes close but my guess is that it does not support image fields (I could be wrong)) then I will probably have to end up implementing my own module to do this. If I do this then I will let you know.

Heres a question though: What do you suppose the best way to do the import would be? Point the module to a certain content type, a certain image field in that content type, then point it to a folder on the server containing images? Then just have the module create nodes with empty titles (or with the title matching the image title), and having all empty fields except for the specified image field? Just trying to think what would be most useful before I set out and try to do this.

vordude’s picture

Sorry, I missed your reply here.

I haven't looked at node_import.

I started hacking together the image_import.module that's a part of the image package. I'm currently hardcoding the content type, and the imagefield field name. But can make them both (I think?) a user setting.

Here's the workflow in my head. (mosly ripping off the image_import stuff)

The user defines an upload folder in the file system. The user FTP's the photos to the specified directory.

Then goes to a page like admin/content/imagefield_import There he can see information about each of the photos in the directory, and create title an body text for each one. The Title text can be prepopulated as the filename, but can be edited

There's a column of checkboxes, for which ones you want to import.

Submit the form

A node is created for each image with title and body text (you just defined) and an imagefield with your newly imported image.

The files are programaticly copied to within the file system (normal localtion)
The origional files are deleted from the upload folder after being imported.

-----------

I have this Mostly hacked together, Essentially functional.

It can look at the import directory, create the import form, Create the nodes, copy the files, and delete the import directory files.

I'm having issues programatically populating the imagefield. I'm not sure what the imagefield is looking for as far as:

 $node->field_image = $some_value_goes_here

Currently my $some_Value is the filepath of the image (Which is what It was with the image.module)

I know that's not right because the imagefield is coming back blank, (actually throwing this error:)

warning: Invalid argument supplied for foreach() in ...modules\imagefield\imagefield.module on line 175.
warning: Invalid argument supplied for foreach() in ...modules\cck\content.module on line 373.

..repeated as many times as images I'm importing

Ideas?

I think this kind of thing would be helpful to a lot of Photographers, and Photo blogs.

vordude’s picture

I got an e-mail from dopry (who's in Boston at Drupalcon, and thanfully took the time to throw me a bone.)

http://drupal.org/node/201594

The answer is something like this:

   $node->field_image = array(
     array(
      'title' => basename($filepath),
      'filename' => basename($filepath),
      'filepath' => $filepath,
      'filesize' => filesize($filepath),
    ),
  );
jplichta’s picture

Looks like you beat me to it. I just did a print_r($node->field_image) on one of my sites using image field and got something lke this.

Array
(
    [0] => Array
        (
            [fid] => 81
            [title] => title
            [alt] => alttext
            [nid] => 19254
            [filename] => imagefile.jpg
            [filepath] => files/imagefile.jpg
            [filemime] => image/jpeg
            [filesize] => 200619
            [view] => <img src="http://fullpathtoimage"  />
        )

)

Let me know if you would like any other help developing this. As I said earlier, this would be very useful for me as well!

vordude’s picture

Jeremy:

Glad to see your interest.

I did get commit access to CVS, and have my early version in the Drupal CVS.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/imagefield_...

This is my first shot at a module. Would love any help you can give on the project.

I welcome your e-mailed offer to be a co-contributor/maintainer.

Thanks

vordude’s picture

Jeremy:

Glad to see your interest.

I did get commit access to CVS, and have my early version in the Drupal CVS.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/imagefield_...

This is my first shot at a module. Would love any help you can give on the project.

I welcome your (e-mailed) offer to be a co-contributor/maintainer.

Thanks
Matt

Anonymous’s picture

Subscriving, this could be just what i want/need.

The embedded media module support image imports to imagefields, but it uses flickr to import from (only option so far).

Big problem with that is the Yahoo copyright issues, ie, anything uploaded to flickr (or any yahoo server (and likely any other photo content host)) auotmatically becomes theirs, you lose copyright over it. Not good at all for a photo hosting site where copyright needs to be maintained.

Anonymous’s picture

Just tested this (checked out from CVS).

Works great. Very impressive!

Now, all it needs is ability to set tags.

Reason?

Set tags as taxonomy (select from import filter perhaps), and then with the right views set up, image galleries are automatically created based upon taxonomy term.

'Set' import would be good.

For example, if you could have a folder in the import folder, with the images, and maybe an xml file with metadata?

I'm no programmer, but if this could be done, then this module deserves to be available for all to download/use as it has great promise I think.

coupet’s picture

Also, an option to import title, description and image from csv file.

----
Darly

Anonymous’s picture

Yes, csv would be useful, could just use any simple spreadsheet (even google's) to create:

title, description, tags

Would be good.

There are various CSV modules in existance, so many code from them could be used to add it?

avolve’s picture

Firstly, thank you for your work on this. I have only tested on a local install so far (MAMP, OS X 10.4.11, drupal 5.7, PHP5) and thought i would share some feedback and suggestions.

When you use this module to upload images you are given text fields for the node title and body. Is there a way you could integrate this with imagefield to include 'custom alternate text' and 'custom title text' (these are used by lightbox2, for example). If it could be tied into whether they are enabled by imagefield it would be even better. This would be an asset to this module (I would have a go, tho my php skills are not up to standard yet).

Another addition would be the option to select (or add, for free tagging) categories for each image. I know this is a work in progress, though though i would give some initial impressions.

The final question i am not sure if there is an answer for as yet (or another solution) is in regards to using this module for a production site. Is there a means aside from FTP to upload images to the specified import folder? I see this as a limitation (it is possible i have overlooked something).

thanks again,
c.

avolve designs | ethical by design

vordude’s picture

I've let this one sit on the back burner, sorry to everyone who has replied. I just found them all tonight.

I see there is some interest here, perhaps I'll get a release together.

Thanks for all of the feedback.

whereisian’s picture

More good news. It's been a good drupal day.

Are you planning on getting a project page going?

vordude’s picture

Ask, and you shall receive.

Project Page

vanderlip’s picture

This is excellent.

Thank you so much for your work on this. I tested it out and it works great.

Is there any way that other CCK fields that already exist on the node could also be presented on the imagefield import page so they could be manually populated in the same manner as the title and the body? I have CCK Node reference fields, and a date module field that I use to link images to people. Allowing this would really create a complete mass upload solution.

Thanks again

gaele’s picture

vordude, you rule!

Excellent module.

Just one note: in the latest imagefield_import.module (1.4) hook_perm() should be imagefield_import_perm()

Jan van Diepen’s picture

Great stuff!

Thanks a lot, I like it very much, but there's an issue with the image module.
The _image_filename() function is already declared in the image module.
Commenting it out in the .module file solves the issue.

Furthermore there is a typo in the .install file.
function image_import_uninstall() is already defined in the image_import module.
It should obviously read function imagefield_import_uninstall().

Keep on perfecting it.

whereisian’s picture

I've been looking for something like this. I'll try it out when I get a chance.

whereisian’s picture

Got this on first install:

Fatal error: Cannot redeclare _image_filename() (previously declared in F:\www\xampp\htdocs\mediamanager\sites\all\modules\image\image.module:998) in F:\www\xampp\htdocs\mediamanager\sites\all\modules\imagefield_import\imagefield_import.module on line 409

I fiddled with it, disabled image module, and gave it a whirl. I works pretty much as advertised. This is huge for me. Could it assign cck field values also?

Thanks very much!

thekgc’s picture

I am having this same issue.. but, now that this error is there, the site is not accessible.

Error:

Fatal error: Cannot redeclare _image_filename() (previously declared in /hsphere/local/home/xxxxxxx/thekgc.com/community/modules/image/image.module:935) in /hsphere/local/home/xxxxxxx/thekgc.com/community/modules/imagefield_import/imagefield_import.module on line 407

Any thoughts as I have no coding experience, if you are posting code, please post where it goes exactly.

I should mention this is the 3rd time I am re-installing this site becuase of this problem and i'm just a little frustrated with this problem.

If I have to start over again, I will, but if someone has a fix please post.

Thanks,

Tom
www.thekgc.com

whereisian’s picture

vordude setup a project page.

I'd report any issues there.

marcoBauli’s picture

still worth testing the patch going on at http://drupal.org/node/251096#comment-886663 ;)

cheers

----------------------------------
Notepad|Drupal Services

erifneerg’s picture

this is what i used to fix the issue. not perfect but it works
http://drupal.org/project/imagefield_import

1kenthomas’s picture

^^^Note this thread led to the creation of imagefield_import, a module which (to clarify) creates multiple cck nodes from a given series of images, uploading the images to those node's imagefields. Might be a good idea to close this thread and direct everyone to http://drupal.org/project/imagefield_import .