I'm familiarizing myself with the Image module and trying to work out how to use it in my project. I'd appreciate advice from anyone who is familiar with its API, which appears to be largely undocumented.
My needs are fairly simple to state:
1. Upload and store an image when the user submits an Add/Edit Story form in which a #type=file field is embedded.
2. Report the uploaded image's node ID to the form's submission callback.
I assumed that the Image module's API would have a function that did exactly this, or some equivalent. I looked at the code, though, and I can't find it. Instead I found a function named image_node_form_submit() which appears to be a form submission callback function in its own right, with all of the image processing logic (generating derivatives, etc.) done in-line. That makes it appear to me that the Image module doesn't offer any means of uploading and processing an image without processing a separate form.
If it's difficult to invoke the Image module's upload service from another form I guess I will have to write my own code, and it shouldn't be too hard. I'd rather use the Image module, though, if I can do so without tying myself in knots.
Comments
Question #1 answered
I found the answer to question #1: the Image Attach module lets me attach images to other types of nodes without any need for programming.
Image Attach eliminates the immediate need to answer question #2, but I still want to find out; I'm very likely to need the information sooner or later.
Drupal 6, CCK, user info
Yes. For some hours I too have been looking for help on using the Drupal 6 CCK + Image modules.
There is a basic requirement that occurs frequently on many web sites such as clubs, on-line stores, etc. One or more authenticated users need a customised content type with fields, to upload and display three things for each node (eg, each product):
- a photo (maybe more than one)
- some basic data (size, price, name, reference, etc)
- some text (description, etc)
CCK looks as those it does this but I am not sure. Here is what I don't know at this point:
1. is the Drupal 5 CCK manual valid?
2. how to display the photo (not a link) without cutting and pasting a file path?
3. how to get the items displayed in a particular order (Heading, Photo, Data, Text) and position?
-------------------------------
. . . later . . . here are some answers:
1. Largely, yes. The Advanced Help module is also useful but with patience and testing you can work it out. Is there a video on completing a typical task like this?
2. Images will be displayed if you enable this (on the content-type edit tab). Lightbox2 and JQuery Lightbox look fantastic (hats off to the Irish). I will be looking further at these (not sure what impact they will have on my shared server).
3. CCK lets you fix the vertical order of fields and field groups. Am still looking for an add-on that lets me put groups side-by-side.
If I find anything else I'll add it here - there must be others out there.
fabius