This issue is for testing and development of the ImageField D6 port. The D6 port is happening in imagefield HEAD.

Please do not *subscribe* to this issue.

The D6 ports of both imagefield and filefield will include a field_file.inc.

field_file.inc will:

  • house functions common to imagefield and filefield
  • partially implement hook_file
  • clean up error messages and logging from core file.inc functions

If you wish to participate in the D6 port of imagefield, only issues with patches will be accepted against head until an alpha released is reached. If you file an issue without a patch before the first alpha I will close it.

Consider this issue informational, there should be little or no need to comment on it. If you wish to file a patch against HEAD open a new issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered’s picture

Initial patch to make the field actually show up; I fully expect some of these changes to be reverted, but it does make the field show up.

There are still a lot of issues with this port so unless you plan to debug it don't bother installing.

Deciphered’s picture

Revised patch, use instead of the above patch.

ImageField now displays and files seem to upload ok.

Deciphered’s picture

New Patch:
- Added JS file back into the module
- Changed calls to _imagefield_file_load() to field_file_load()

Deciphered’s picture

New Patch:
- Two references of '_imagefield_file_delete()' changed to 'field_file_delete()'

rapsli’s picture

tried to apply patch against head, 1 hunk failed:

***************
*** 56,62 ****
// if we're creating a new revision, return an empty array so CCK will remove the item.
if ($node->old_vid) return array();
// otherwise delete the file and return an empty array.
- if (_imagefield_file_delete($file)) return array();
}

// set permanent status on files if unset.
--- 56,62 ----
// if we're creating a new revision, return an empty array so CCK will remove the item.
if ($node->old_vid) return array();
// otherwise delete the file and return an empty array.
+ if (field_file_delete($file)) return array();
}

// set permanent status on files if unset.

I would gladly be testing, you got to give me a running version though

Deciphered’s picture

@rapsli - Make sure you are patching against HEAD, I just tested the patch myself and it worked perfectly.

If you haven't got CVS setup you can always use the web-based CVS repository and save each file: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/imagefield/...

Deciphered’s picture

Updated patch:
- Stopped Imagefield hijacking Node title.

bbeyer’s picture

I have tried this patch and the previous one. The patch seems to work for adding inmagefield to my content type. But when I view pages that use the imagefield, I get an error. It says my maximum execution time(30 seconds) has been exceeded on line 468 of the imagefield.module

Steve Dondley’s picture

I'm seeing basically the same thing except I see it on line 458. I first got this error after trying to upload the image through the form. AFter that, all pages return this error to me and the error is reported to happen on line 460.

I have to set the status of the module to 0 in the db to fix.

Steve Dondley’s picture

It has something to do with the unset($items[$delta]) line. When I comment it out. Things work. I wonder if it has something to do with the fact that $items is passed by reference. unset behaves differently on variables passed by reference. See http://www.php.net/unset

But I really have no clue what this section of code is trying to do or how it works. So I'm just blowing smoke.

Steve Dondley’s picture

OK, changing the line to
$items[$delta] = '';
works.

Doesn't seem to break anything. I can even do multiple images on a node (which I assume the $delta is for).

rapsli’s picture

are there any plans for a first dev release? ... it would make testing easier

bbeyer’s picture

#11, fixed my timeout problem, but now the image doesn't show up when viewing the piece of content

Steve Dondley’s picture

bbeyer, is working for me. Make sure you have cck settings configured to show the image.

catch’s picture

Status: Active » Needs work

This is a patch.

bbeyer’s picture

Steve, do you mean in the field settings for the imagefield of my custom content type? If so, I am not sure where I can change that. Or are you talking about a general option for the CCK itself?

Steve Dondley’s picture

bbeyer, you have to dig into the code around line 460 and change it from unset($items['delta']) to what I put in comment #11

bbeyer’s picture

Steve,
I did that and it all seems to work except that the image doesn't show up when I view the node. I have tried all the different display options in the administration side of the content type and can't get the image to appear. When I first upload the image and preview the node it looks ok, but as soon as I save it, the image does not appear.

Steve Dondley’s picture

If I recall, I think I might have had the problem at first but the problem seemed to have fixed itself. Maybe it's a cache issue.

Moonshine’s picture

yes... clear your cache. :)

Vigile’s picture

I installed the latest HEAD version with patch 5 and can upload files just fine. They aren't showing up at all though -- is this normal for this state of the module patches?

Moonshine’s picture

Display works, make sure you have cleared Drupal's cache. You can also check to make sure the field is set to display in "Display fields" for that content type.

bbeyer’s picture

yep, clearing the cache fixed my display issue

webchick’s picture

I get a bunch of notices when uploading an image (just used default options on the field):

    * notice: Undefined index: #image_required in /Applications/MAMP/htdocs/6x2/sites/all/modules/imagefield/imagefield.module on line 275.
    * notice: Undefined index: alt in /Applications/MAMP/htdocs/6x2/sites/all/modules/imagefield/imagefield.module on line 131.
    * notice: Undefined index: title in /Applications/MAMP/htdocs/6x2/sites/all/modules/imagefield/imagefield.module on line 131.
    * notice: Undefined index: alt in /Applications/MAMP/htdocs/6x2/sites/all/modules/imagefield/imagefield.module on line 806.
    * notice: Undefined index: title in /Applications/MAMP/htdocs/6x2/sites/all/modules/imagefield/imagefield.module on line 807.

Also, here's a re-roll from the imagefield root directory, so you don't have to type the file names in manually.

Deciphered’s picture

@webchick

I will try to take a look for the cause of the issue as soon as I get a chance.

One thing I did notice is that your re-roll excluded the 'imagefield.js' file, I presume this isn't intentional?
If you get a chance can you re-roll? If not I will do so myself when I have the time.

webchick’s picture

Oh, dang it. :P Sorry about that. Thanks!

jbrauer’s picture

Tested #26 and it generally seems to work.

The only problem I ran into was that after uploading the maximum number of images the add image form is still displayed and while the page shows a warning that you can only upload X images it allows adding at least X+2 images which then have to be removed with a preview and checking the delete boxes to get the count down to the minimum.

dopry’s picture

The ports in the patches to date are solely functional ports which do not leverage any of the new api features available in D6. I'm not going to accept just a functional upgrade to imagefield. There are two features in particular which should be leveraged. CCK's multivalue handling and FormAPI's #value_callback feature.

Ideally the #value_callback for the imagefield widget saves an uploaded file, and the process callback displays either a file upload form or an image edit form. I'm also adding a new column to imagefield for D6 called data, in which widgets can store serialized data. This is to provide a place for widgets like eyedrop and imagefield_crop to store their information on a per image basis. or for widgets to implement caption txt etc.

.darrel.

dopry’s picture

some of the first steps of leveraging the #value_callback and CCK's multiple value field are complete. the imagefield_widget_value callback is now saving uploads, but not passing them back to the field. CCK is in fact handling the multiple values currently though....

next steps: save fid associations, processing for widget if #value is not empty.

Moonshine’s picture

Just a heads up that in D6 file_save_upload() saves files with a "temporary" status flag which you have to update or the files are deleted during cleanup.

From the API:

The file will be added to the files table as a temporary file. Temporary files are periodically cleaned. To make the file permanent file call file_set_status() to change its status

Ran into it today with some other code...

Rowanw’s picture

Applied the latest patch to HEAD but 8 out of 15 hunks failed:

patching file field_file.inc
patching file imagefield.install
patching file imagefield.js
patching file imagefield.module
Hunk #1 succeeded at 79 with fuzz 1 (offset 6 lines).
Hunk #2 FAILED at 104.
Hunk #3 FAILED at 267.
Hunk #4 FAILED at 456.
Hunk #5 FAILED at 468.
Hunk #6 succeeded at 296 (offset -191 lines).
Hunk #7 succeeded at 510 with fuzz 1 (offset 6 lines).
Hunk #8 succeeded at 350 (offset -191 lines).
Hunk #9 succeeded at 780 (offset 120 lines).
Hunk #10 FAILED at 794.
Hunk #11 FAILED at 824.
Hunk #12 FAILED at 835.
Hunk #13 FAILED at 860.
Hunk #14 succeeded at 633 (offset -242 lines).
Hunk #15 succeeded at 1032 (offset 120 lines).
Deciphered’s picture

@Rowanw

dopry has made some changes to the way Imagefield works and I presume will continue making these changes, as to not step on his toes I will probably not attempt any more patches for the moment. You can however download imagefield.module version 1.38 from here and you will be able to apply the patch.

Also note that while fetching the above link for you I noticed that dopry has not updated imagefiled.module to version 1.42, it is quite possible that he has got it to a working stage where you won't even need a patch. Test that first, if that doesn't work then what I said above should work.

dopry’s picture

@Moonshine: Thanks for reminding me about file_save_upload and the Temporary status flag. I wrote it, but seemed to forget it... :)

@deciphered: I think the widget interface is in it's general form at this point, more so than it was with earlier patches. I'd really love to have more eyes on it at this juncture, even though it isn't fully working... If my description of how the widget should work is too obtuse feel free to ask questions. It will help me understand what needs to be documented...

@todo: image form testing... we need to be able to delete, and change alt/title. set file status in hook_field on node save. begin improved ajax upload code that replaces a single image widget. instead of the entire form structure.

.darrel.

alippai’s picture

When will an alpha/beta release avaible?
I read that there are only few bugs there now.
Or is the HEAD in CVS the actual dev version? - it's a 3 week old code :S

Deciphered’s picture

@alippai,

The helpful thing to do would be to test the latest version in HEAD (which is 8 days old, not 3 weeks old) and if you find any bugs report them or attempt to fix them.

rapsli’s picture

tested latest head. Two Bugs:

When I create a new node and then hit the upload button the node is being saved instead of just uploading the image.
Image is not being uploaded as my files directory stays empty.

alippai’s picture

So my test:

ImageField - latest HEAD
CCK - 2.0 beta
Private file handling, path set to '../files' - it's the first time when I use private file handling, so there can be problems
clean URLs - ON

I can't save imagefield settings in a node type, I get this error when I submit the form :

* warning: strtr() [function.strtr]: The second argument is not an array in E:\HostingData\Domains\MYSITE\wwwroot\modules\syslog\syslog.module on line 108.
* The default image could not be uploaded. The destination(../files) does not exist or is not writable by the webserver.

The forms action contains the index.php?q= part of the address, but clean URLs are enabled and they are used on the other parts of the site...

EDIT: The default image checkbox is unchecked.

catch’s picture

Is your files directory writable then? You should check upload.module with that setting since nothing in that error message mentions imagefield.

alippai’s picture

IMHO the second error message is the result of this part of the code:

function _imagefield_field_settings_default_validate($element, &$form_state) {
  // Verify the destination exists
  $dst = file_directory_path() .'/imagefield_default_images';
  if (!imagefield_check_directory($dst)) {
    form_set_error('default_image', t("The default image could not be uploaded. The destination(%d) does not exist or is not writable by the webserver.", array('%d' => dirname($dst))));
    return;
  }

so function imagefield_check_directory returns with false for ../files

Upload module works for me.

alippai’s picture

file_create_path('..');

returns false (line ~410 of imagefield.module)

andrewfn’s picture

Webchick, if you would re-roll the patch @26 so that it applies against HEAD then I will test it.
Thanks.

alippai’s picture

There can be a better solution, but this one works for me:

function imagefield_check_directory($directory, $fieldname = NULL) {
  $old='';
  foreach (explode('/', $directory) as $dir) {
    if($dir=='..' || $dir=='.') {
      $old .= $dir.'/';
      continue;
    } else {
      $dir = $old.$dir;
      $old = '';
    }
    $path = file_create_path($dir);
    if (!field_file_check_directory($path, FILE_CREATE_DIRECTORY, $fieldname)) {
      watchdog('imagefield', t('Imagefield failed to create directory(%d) at (%p).', array('%d' => $directory, '%p' => $path)), WATCHDOG_ERROR);
      return false;
    }
  }
  return true;
}
dopry’s picture

allipai: file_create_path(..) should fail. does file_create_path (../files) fails? There is a function file_check_location that verifies that the path is within the files directory '..' is most certainly not in the files directory. Maybe there is an issue with field_file_check_directory() I over looked.

@all:
really if you want to file an issue against HEAD open an issue for it, do not use this issue. What part of

Consider this issue informational, there should be little or no need to comment on it. if you wish to file a patch against HEAD open a new issue.

do you guys not understand?

dopry’s picture

Status: Needs work » Closed (fixed)

see 6.x-3.x.