I have made a custom module where I load the create node form for an "announcement" content type.
What i want
Besides the text and select fields, I require an image field which supports multiple image upload (up to 4 ). The images should be uploaded to a temporary directory and load in the form a thumbnail for preview , and on form submit the images should be permanently saved . In case I refresh the form page , if I already selected the images they should still display on the form as thumbnails. After form submit I want to use the first image ( of the max of 4 uploaded ) as a preview image for the announcement and the rest to be shown when the node is viewed (using views module).
What I have
I made an image field with multiple values set to 4, I tried to hide the button for upload so the image is saved only on form submit, but I can't upload but one image on submit. If i leave the upload button , the user can click it , upload the image and do that for each image. But if i refresh the form page the thumbnails are not loaded at all, even though the files are saved on the server. After form submit I get all the images in the box for previewing instead of 1 .
Right now I am lost on how to approach these issues. I am not afraid to do this programmatically, but I don't know which functions should I look for, if i should keep the field and edit it or add the field programmatically and set its functionality as well. Or can this be solved by a few settings that I missed? Or is there a module out there that already did this so I don't have to reinvent the wheel?
Any help is most apreciated,if required I can attach the code for the module as well.