I've done some searches on this and everything that I can find seems to be pretty old and more concerned with getting images into a blog or textarea. My question is this:
What is the best way to add an image upload element to a node type? I am working on a module that need to allow two images to be uploaded along with other custom data. When viewed, the images must be shown as thumbnails that link to the larger images.
Our current thought is to replicate the code from image.module into our custom modules, but that seems messy. Is there some sort of module that I missed that works like upload.module?
Additionally, can anyone point me to some decent documentation for files management? The code documentation seems pretty light.
Any ideas on a more elegant way to go about this would be appreciated.
Comments
Definitely re-use image.module
Image.module is meant to be used as an API, and does everything that you describe. It sits on top of the file API (i.e. upload.module) and would handle that for you.
Contact walkah, the image.module maintainer, if you need more info.
img_assist
you might look at the img_assist and the way it handles it for some ideas
-sp
---------
Drupal Best Practices Guide - My stuff Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
I finally got it
After a good amount of trial and error, I finally got it to work for me. It boiled down to an issue of my using module_invoke to call image_validate. The $node->images were being lost. Once I called the function directly and passed in the reference to $node (aka &$node) the images elements made it back up to my module.
I wonder if there might be benefit to adding a comment in the code (and therefore doxygen documentation) to note that image_validate is acting on the $node object? That doesn't seem to be a standard practice, as far as I can tell, and someone new like me can easily miss that.
Anyway, thanks for the encouragement. I'll try to post my final code for other people when I get a chance.
--------------------
Sean B. Fuller
www.seanbfuller.com
Here is my final code
Here is the final code that I ended up using for anyone who is looking for an answer to this question:
http://drupal.org/node/30944
--------------------
Sean B. Fuller
www.seanbfuller.com
Please provide a patch to image module which adds this comment.
Thanks!