I'm pretty certain that imagefield will eventually support referencing existing images. So in the meantime I'm using this code as a bit of glue to get this functionality. I'm sharing it here in case someone cares enough to improve it - it's good enough for our purposes.

Our procedure now is to create an "image collection" cck type with a mutiple imagefield field. So the user can create a collection of images called "splash screens" or whatever. This creates a database table where the image references are stored.

The code attached here is a (more-or-less) complete field module that lets you specify which existing imagefield field you want to reference images from. It then wrappers the imagecache formatters so that you have the same display options as with a normal imagefield.

Issues:
-- It uses a pretty raw method (not robust) of gathering a list of available images - see imageref_widget()
-- Referenced images would be easily broken by removing the target images, there are no measures to prevent this. You might form_alter the imagefield form to prevent referenced images being deleted.

CommentFileSizeAuthor
imageref.txt5.27 KBsime
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

oooh. very interesting. i'd love to hear opinions from dopry or quicksketch

Bevan’s picture

subscribing

sun’s picture

As I already mentioned in the Re-use of existing images issue, I'd propose that Imagefield should only offer the possibility for other modules (providing a suitable UI) to re-use (or reference) existing images. I don't know if it's a good idea to speak of "referencing", because this would implicitly mean that images are separate entities. Imagefields can be assigned to different content types and none of them has to be a pure "image content type", or like in this example, a content type to build galleries.

sime’s picture

Status: Needs work » Closed (won't fix)

Hi Sun.

Yep, "reference" is to the fid with a filter based on an existing image field. I'm guessing it's a pretty narrow use case.

Anyroads, I don't have any goals to get this in Imagefield, just wanted to expose the idea and share it and I'm ready close it now. Cheers.

scottrigby’s picture

Hi - Has any workable solution for an image collection been found? (ultimately, I just want users to have an image library to choose from - ideally they'd also have a choice to also upload one of their own if there's none in the library they like, but I could just accomplish this with another field and use some logic in the template to show whichever one they pick)
Thanks in advance for any updates on this!
:) Scott

rodmarasi’s picture

is this issue solved? its a good idea to have an image field that can reuse existing uploaded images. the problem with IMCE is that it is not an image field, cannot easily be manipulated by views module.

rodmarasi’s picture

sorry, i guess this solved it : http://drupal.org/project/filefield_sources