1

I need to add a custom field (a simple text field) to the image_field widget in Drupal 7.

The structure is a standard node (called Article) which has zero or more images (related photos or graphics) attached via the image_field widget. The field I want to add is the source of the image, and is used later to figure out when it needs to be deleted.

I've tried the code from this post, but couldn't get it to work.

2
  1. Attaching metadata to images and other media, is precisely the reason that prompted the creation of the media module. We use the unfortunately "unstable" version ourselves, with good results. Using Media, your images becomes entities, allowing you to attach any field you want to them through the normal means.

  2. While the solution to manipulate the existing widget is fully valid, it will require quite a bit of understanding of the Field API, and I believe any such solution would get rather messy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.