CCK ImageField - reuse images?
Rob_Feature - March 9, 2007 - 22:31
The Background:
I'm modifying the content type "Event" that installs with the event module (just adding some fields with CCK). I added an image field, using the imagefield module. I have multiple events that will be using the same image.
How Do I...
So, the obvious quesiton is, how do I re-use the image I've already uploaded for the previous event? I don't want to upload a new image each time, as it creates new files called image-1.jpg, image-2.jpg, etc. Is there a way, in the imagefield module, to reference a file already on the server and in the directory that imagefield is using? Any answers are apprecaited. Thanks!

It's a good question, but I
It's a good question, but I dont think that you can achieve this using the imagefield module alone.
You could use a nodereference field type and restrict it to image nodes in combination with an image field, If you were adding an existing image you would use nodreference, otherwise you would use imagefield. Group them together in a custom fieldset to make it slightly less unusable.
There is, no doubt, a better way of doing it. Would be a good feature request for imagefield (if it is not already in the queue.
There is talk of file uploads becoming standardised (all using a common api) - this would be good because the problem seems to exist with standard file uploads as well - if the file already exists you cant reference it.
let us know what you come up with.
Universal File Reference...
Yeah, universal API for file reference would be fantastic. Right now, I'm using 5 different modules to upload files, and it puts them all in different folders in different ways. This does seem like a good thing to standardize.
As far as nodereference, let me see if you can clarify something for me: Does your image that you're referencing have to be a node? (as in, an image node using the Image module)
If that's the case, it would be two separate steps to create content: First creating the image, using the image module, then creating the content using your CCK type. Is that correct?
I'm no programmer (i'm a themer), so I'll just cross my fingers that all you smart people come up with a solution sometime. I'll look at the imagefield module, in the meantime, and see if anyone has suggested this functionality.
Thanks!
Yes, if there was no
Yes, if there was no existing image it would need to be added .That's where the image field comes in - if the image exists you can use the nodereference field to find the existing node, if not you can use the image field.
I do recall hearing about a module that enhances the functionality of the image attach field to allow multiple fields. Dont know if this was just a concept or it actualy exists, but it would solve your problem. Image attach does not exist as a content field, but is added to any relevant node edit form.
Could be worth looking into.
Node vs. File
Hey gollyg...
Thanks for your help/responses. However, I think maybe you're missing something about my question: When you use the imagefield module to add an image to a CCK type, it does NOT create that image as a node. It's just a file uploaded to the server and displayed (at least, to my knowledge).
So, the nodereference wouldn't help, because the images that would be uploaded would NOT be nodes. Does that make sense? Or am I missing something...
no, i didnt miss anything in
no, i didnt miss anything in your question - i understood what you meant. I did, however, give you a wrong answer :P
I have actually been working with image field and image cache and did not realise that it was not creating nodes! I know that there are some other modules that attach images as files, but i thought this one was creating them as nodes.
so you are correct in saying that my solution is not going to work.
sorry
But with a nodereference to
But with a nodereference to an image node, the page doesn't show the image, only a link.
Is there a way to get a thumbnail?
Anyone Else?
Anyone else have thoughts on how to do this? Is there a better module/setup suited for this than imagefield?
I've decided to use
I've decided to use image_attach, which comes with the image module.
Drawbacks:
- once a node has an image attached, you can't remove it. You can choose a different image, but you can't return to the node having no image
- you can only have one attached image per node
On the plus side, new images attached to a node are themselves created as nodes. Perfect for re-use!
you might also try upload_image
Instead of Image Attach, you may want to consider using upload_image, which turns the standard upload field into a tool that creates a mini gallery on a page (if you choose to list them) when you use it to upload a bunch of images. It also creates nodes for each of the images and provided a link on the image node back to the originating article. As far as I can tell, it does everything attach_image does, without the two major drawbacks that you mentioned. Removing images is as easy as unchecking the "list" box or checking the "delete" box and submitting the page.
I really loved that functionality. In one simple step I could publish the article, attach an associated image gallery and create all the image nodes, which could later be tagged with taxonomy for better image browsing.
As much as I enjoyed using upload_image, I have had to abandon it in favor of all the great benefits of using imagefield and imagecache. I would love to see this ability added to imagefield module, where you check a box to indicate that you want a node created for the image, and when the form is submitted, all the checked nodes generate the specified image type and share the imagefield values. I certainly don't want to make every image into a node, but often this is great functionality. I imagine that this functionality could be added to imagefield and cck, but we'll have to work out how multiple nodes can have a file reference to the same file for this to really make sense.
I know this seems like ancient history
but for the benefit of others who come across this searching for a solution (which apparently still doesn't exist?)
Upload Image does indeed work well for what it does, although I'd really like it better if it:
or
and
I'm using the Image module's included Image Import module - it doesn't create a "parent node", but does do that last bit with the term so it's easy to then use Image Assist to associate the image nodes with any other node type.
Also I believe the problems with Image Attach that joachim mentions have been fixed.
You CAN now remove an
You CAN now remove an attached image.
Still limited to one image per node though :(
There's a monster issue on this, and help is needed testing a patch!
Image Attach's one image
Image Attach's one image limitation is by design right?
And the old inability to remove an attached image is completely gone?
So what's the monster issue? I'm happy to check it out and help if I can. . .
> Image Attach's one image
> Image Attach's one image limitation is by design right?
Well yes, in the sense that that was the original intention, but it's pretty crummy design.
The monster issue is for that.
A year and a half later
So, here we are a year and a half after my original question. There's no easy answer as of now, but there is some hope. One of the modules that does this 'reuse' issue really well is Asset module. If all goes as expected, it looks like the future of Asset module is headed towards being just a upload/file management wizard that other modules (including filefield/imagefield) would use.
If that ends up happening, it makes this reuse issue very easy and starts to allow all different types of uploaded files be reused as well. I'd expect that, in the coming years, this type of thing will make it into core. But in the meantime, I'm hoping that Asset module will become the hero and solve this issue.
Still no answer for imagefield
Came here to find a similar module like image_attach but for imagefields. But this discussion has grown about pros and cons for iamge_attach and image.module.
But image.module is incompatible with imagefield. So this can't help.
Now, is there a solution for the original question or not?
..........
Wilfried
Drupal: a CMS without typo in its name
Yeah hello exactly a year after :-)
I'm looking the same obvious thing - to add pictures (with some caption) and be able to reuse them and quickly search by type (some filter).
And finaly to insert them in artcile in a way that could be mistake-proof (instantly the same position for all articles, but NOT using mce which allows editor to mistake and change the position float left, right, none, center and so on...)
hello drupal world!
Me too
I've been looking for this as well. Assets seems to be abandoned. Media looks good, but is very complex and a long way from finished. I don't know how usable it will.
However, Lullabot made this recently:
http://drupal.org/project/filefield_sources
Looks perfect to me! Only issue is it works on filename. Perhaps someone can provide a patch to show a thumbnail of the selected file via an AJAX load, if it's an image file. That would be cool. I'm going to try it out, anyway. =)
--
http://www.drupaler.co.uk/
Have a look also at ..
Image Browser, the version 2, is doing a very good job at offering a nice interface for images. Make sure you check it out.
http://drupal.org/project/imagebrowser
____________________________________________________________
en: www.couzinhub.com
fr: www.couzinhub.com
Looks good
Unfortunately I can't use it for two reasons:
1. I have waaaay to many files to use an interface like this, I need to be able to tap in a filename
2. I need the selected file to go to a FileField upload field, not the node body field
But it does look good, thanks for sharing. =)
--
http://www.drupaler.co.uk/