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!

Comments

gollyg’s picture

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.

Rob_Feature’s picture

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!

/**
  * Bob Christenson
  * Mustardseed Media
  * http://mustardseedmedia.com
  */
gollyg’s picture

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.

Rob_Feature’s picture

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...

/**
  * Bob Christenson
  * Mustardseed Media
  * http://mustardseedmedia.com
  */
gollyg’s picture

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

joachim’s picture

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?

Rob_Feature’s picture

Anyone else have thoughts on how to do this? Is there a better module/setup suited for this than imagefield?

/**
  * Bob Christenson
  * Mustardseed Media
  * http://mustardseedmedia.com
  */
joachim’s picture

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!

OpenChimp’s picture

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.

HansBKK’s picture

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:

  • Played well with Uploadpath (Image's fault?)
  • or

  • Could be enabled/disabled on a per-node-type basis (to work around the above problem)
  • and

  • Automatically tagged the group of Image nodes created with a selected Taxonomy term

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.

joachim’s picture

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!

HansBKK’s picture

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. . .

joachim’s picture

> 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.

Rob_Feature’s picture

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.

/**
  * Bob Christenson
  * Mustardseed Media
  * http://mustardseedmedia.com
  */
pepe roni’s picture

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?

konrad1811’s picture

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...)

greg.harvey’s picture

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. =)

Anonymous’s picture

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

greg.harvey’s picture

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. =)

ndwilliams3’s picture

It is funny that this has been an on-going issue for so long. Image handling in my opinion has to be the most frustrating aspect in Drupal.

There are so many modules and methods, but it is still pretty much black and white "images as nodes" or "images as fields". I have always used imagefield, imagecache and views for images, either using views-attach and node reference url or popup: add and reference. I really hate the popup method, but it is the only way I have found to add "images as nodes" while creating a node of another content type.

If Image module could be combined with imagefield and imagecache, it would be a great solution and it looks like there has been an effort to work this out in D7. But where does that leave us in D6?

Anonymous’s picture

I recently tried a pretty successful technique to add images as node with imagefield while creating a normal node by using the Nodereference Image Helper : http://drupal.org/project/noderef_image_helper
It is still a popup method, but the module is nicely done, even if still in DEV. You can create images on the fly, or refer to existing one through a view that can be a bit customized.

chowdah’s picture

I just tried this on drupal 6.16, with completely updated dependent modules, but it's not working as expected. Additionally, there is no documentation and the documentation link has 'page not found' errors. Also the home page for the project seems really broken. I think the Nodereference Image Helper module might be abandoned to tell you the truth.

ctpmp’s picture

Quarantine’s picture

Subscribing. I have been wondering about this problem for ages cos it doesn't make sense to duplicate the same image all the time, not to mention that it consumes bandwidth.

vitis’s picture

sub

asb’s picture

Still looking for a usable solution for this, still haven't found an (even remote) equivalent of 'Image attach' for Imagefield images.

All suggested approaches lack at least one important feature: the integration with Views (e.g. like making a tabular listing of nodes with one attached image as the first column; very easy with 'Image attach', but with an imagefield inserted through a filter...?)

scarer’s picture

still looking for a solution to this

konrad1811’s picture

I guess ther is still no good module for this.

I needed this as a basis for news site so I combined some module and work out how to do this.

I use CCK and Image node type to add an image to drupal site and ImageCache to have thumbnail and regular photo size.

Searching an image - I simply did my own filter for that.

Adding it to article [little complicated but WORKS!!!] - I've got my own article type with basicly one image.
I use CCK 2 fields for a) thumbnail image b) regular image c) NID image node number. There is a module to compute (Compute Module?) a field from CCK (forgot the name). Use this module to automaticaly insert code with image nodeNID entered in CCK field in my article type.
I also use some node insert module whith image_filter module which is allows to enter simple formula with NID number to display inserted image. I changed some code in that Image Filter module.

All above is OK but needs little codeing in the filter to have thumbnail and regular photo from inserted image node which I wanted to pass by as I am only amatour programmer... But I managed to solve this :)

uno’s picture

Have you tried http://drupal.org/project/filefield_sources ?

It enables you to use regular imagecache + an option to use previously image on destinated folder on your server (with nice and quick autocomplete) or custom file on remote server.

--
... I mind

greg.harvey’s picture

Hi,

To all the people who keep coming in here saying "I guess there's no solution to this" and "can someone tell me when there is a module for this", despite the fact several people have independently said this, here you go:

FileField Sources

In case you missed that, here it is again, a bit bigger:

FileField Sources

Oh, the link?

CLICK HERE FOR FILEFIELD SOURCES !!!

;-)

uno’s picture

Are you trying to enligten me, haven't you noticed that I also advocated FileField sources?

--
... I mind

greg.harvey’s picture

Not at all aimed at you - for future readers. Sorry if I gave the impression it was. =)

pwaterz’s picture

Filefield sources doesn't work with imagefield.

PJW

greg.harvey’s picture

Yes it does.

pwaterz’s picture

My apologies. I mean that imagefield crop doesnt support filefield sources.

PJW

mbahlol’s picture

subscribe

pwaterz’s picture

I currently have written 2 extensions to filefield sources. Filefield sources taxonomy and filefield sources node title. What these modules allow you to do is to find files based on taxonomy, and find files based on node title. Also if the filefield is an imagefield it will display an image in the autecomplete instead of just the filename. I want to contribute these modules but the CVS/GIT application process is taking forever. I have an application in process for one of my other module filefield audio insert, this needs to be approved before I can contribute these other module. If you have interest in these module please go to my CVS application and leave a comment asking for my approval. Link to my CVS application http://drupal.org/node/938726. Thanks for the support.

PJW

mbahlol’s picture

Hi, this is what i do, i make two type of nodes. first node named picture with imagefield, and story node with node reference explorer to browse existing image and automodal + Modal Node References to insert new image. this is solve my problem. maybe there is any better idea please let me know, i'm still stuck in how to upload new image in node reference explorer box.

Story node type