This is an extensive patch that fundamentally changes the way ImageField works.

The current ImageField in Drupal 6 attempts to piggy-back off of FileField while providing its own CCK field type. This approach requires ImageField to implement hook_field() and several FileField custom hooks, many of which are buggy or not being used at all.

I've been fixing several issues in the FileField queue, such as broken revision handling (#370531: Properly Handle Revisions for document control) and duplicate uploads (#370015: Upload issue with clicking 'Add another item' multiple times (Repost w/ screencast)). However, these problems still exist in ImageField since it uses it's own hooks for managing its fields.

In short, we've got a lot of duplicated code between ImageField and FileField, and the code that is shared between the two is shared by mechanisms that CCK was not made to handle (i.e. it's all a bit of a hack to work around limitations in CCK).

So this patch removes the "Image" field type, and makes ImageField a pure widget for FileField. This means less code in ImageField, more reuse, and less bugs. The only side-effect of this is that all the formatters specific to ImageFields are also now available to FileFields. However, ImageCache already provides all its formatters to FileField anyway, so this isn't that big a shift.

This patch refactors ImageField to make it a pure widget. It also fixes the upgrade path between the Drupal 5 1.x version of ImageField and the current 3.x. This patch needs to be applied to both FileField and ImageField at the same time.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Revised patch with a few less code style fixes unrelated to the issue.

quicksketch’s picture

Updated patch that also regenerates thumbnails with a better path. This was suggested in http://drupal.org/node/385726#comment-1307422.

quicksketch’s picture

The upgrade path fix included in this patch also fixes #374764: Drupal 5 Update Breaks Titles and Alt text.

quicksketch’s picture

quicksketch’s picture

quicksketch’s picture

quicksketch’s picture

Status: Needs review » Fixed

Considering the number of dependent issues on this one and my desire to get out a working upgrade path as soon as possible, I've committed this patch. At the very least it's going to fix more problems than it will cause.

RobLoach’s picture

Wow! Nicely done, Nate! Didn't even see this issue... ImageField code is good now!

drewish’s picture

Saw one warning during the update:

notice: Undefined index: image_path in /Library/WebServer/drupal-6/modules/imagefield/imagefield.install on line 122.
Boletus’s picture

This sounds great. Been waiting for the imagefield 6 forever. Good work! Will try to test this tomorrow. Can I use the dev version of ImageField and FileField and not patch anything, or what do you suggest?

quicksketch’s picture

Thanks drewish, I put an isset() check in there. This would have caused upgrading from ImageField d6 to this new version to lose any custom file paths specified.

himtuna’s picture

Hi, I don't know how to apply a patch.
Please can someone give me a working file of imagefield.module

That would be really thankful.

EDIT:Please this is an emergency, I am building my site and everything seems to be broken, I someone could send me a working module of filefield and imagefield. Please please please.

quicksketch’s picture

himtuna: get the development versions which have all the patches applied. Visit the project page for ImageField and FileField, click "View all releases", then download the 3.x-dev versions.

himtuna’s picture

Oh! Man thanks a lot
You know when you work hard all day long on our weekends, your head just don't work

Thanks a lot for this module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.