Hi,

I'm experiencing a strange problem with imagefield when adding or editing a product node:

In IE7, upload works fine, but when clicking the "Add another item" button to add fields for uploading another image, the whole imagefield part of the form just disappears.

The page doesn't reload, and there's no problem in Firefox, so it must be a javascript-issue. (Which leaves me clueless since I have no js debugger for IE).

This problem only occurs with Ubercart product nodes. Other nodes with identically configured imagefields work fine.

I'm using:
Drupal 6.9
Ubercart 6.x-2.0-beta5
CCK 6.x-2.2
ImageField 6.x-3.0-beta3
ImageAPI 6.x-1.5
ImageCache 6.x-2.0-beta8

Hope someone can help, thanks!

Comments

Island Usurper’s picture

The way Ubercart 2.0-beta5 sets up the image field for products is incompatible with Imagefield 3.0-beta3. If you upgraded Imagefield after letting Ubercart create the field, it should be fine, though.

If you add another image field to the product type, and it doesn't have this problem, please post an export of those two fields. If it only works on a different content type, export that too.

rsm08’s picture

Hi IU

Actually, the reason I upgraded both ImageField and Ubercart was the occurrence of the problem, so it was there already, before the imagefields became filefields.

To answer your question though, I upgraded Imagefield after Ubercart had created the field.

I tried to add another image field to the product type, but this makes the same error.

I tried it on the "article" content type, and here were no problems. I'm still a drupal noob, so forgive me for asking stupid, but whats an "export" exactly and how do I make it?!

BTW, wouldn't it be more intuitive to have the form add a new blank image field automatically, every time an image is uploaded, so there is always a single empty field available, instead of having an "Add another item" button, which I'm afraid will just confuse users?

Island Usurper’s picture

It might be more intuitive to do it that way. You should ask the people maintaining Imagefield in that module's issue queue. ;)

In the Content type settings there should be a tab called Export . This page lets you generate the PHP that defines the content types and their fields. Ubercart uses similar PHP to create the image field for the product type, so I want to see how it's different from what you have.

sam_RiteTimeDirect’s picture

You say that UC beta 5 is incompatible with Imagefield 3.0-beta3. I have been trying to add an image to a product and keep getting an error Fatal error: Call to undefined function imagefield_content_is_empty() in /home/ritenec1/public_html/sites/all/modules/cck/content.module on line 900

Is this related to the general incompatibility?

Also, do you know if this issue is being worked out on either the ubercart or imagefield side of things? If not what is my work aournd to post images?

Thanks in advance.

Sam

Island Usurper’s picture

It might be related, but I haven't seen that error before. Get the dev version of Ubercart. It will create the image field with the same data they expect, which includes telling CCK which module handles which part of the field storage and display.

sam_RiteTimeDirect’s picture

OK I found my problem. I had not run update php. Now everything will upload just get the error when I try to preview.

rsm08’s picture

Ok I found the export feature.

Here is an export of the "vareparti" content type which is a product class. Here the problem occurs:

$content['type']  = array (
  'name' => 'Business to business',
  'type' => 'vareparti',
  'description' => 'Consigments of goods or large single items for sale to businesses or sole traders.',
  'title_label' => 'Navn',
  'body_label' => 'Beskrivelse',
  'min_word_count' => '0',
  'help' => '',
  'node_options' => 
  array (
    'status' => true,
    'promote' => false,
    'sticky' => false,
    'revision' => false,
  ),
  'language_content_type' => '0',
  'upload' => '1',
  'i18n_node' => 1,
  'i18nsync_nodeapi' => 
  array (
    'author' => false,
    'status' => false,
    'promote' => false,
    'moderate' => false,
    'sticky' => false,
    'revision' => false,
    'parent' => false,
    'taxonomy' => false,
    'comment' => false,
    'files' => false,
    'field_image_cache' => false,
    'field_video' => false,
    'field_delivery' => false,
    'field_testimage' => false,
  ),
  'old_type' => 'vareparti',
  'orig_type' => 'vareparti',
  'module' => 'uc_product',
  'custom' => '0',
  'modified' => '1',
  'locked' => '1',
  'reset' => 'Gendan standarder',
  'og_content_type_usage' => 'omitted',
  'content_profile_use' => 0,
  'comment' => '2',
  'comment_default_mode' => '4',
  'comment_default_order' => '1',
  'comment_default_per_page' => '50',
  'comment_controls' => '3',
  'comment_anonymous' => '0',
  'comment_subject_field' => '1',
  'comment_preview' => '1',
  'comment_form_location' => '0',
  'fivestar' => 0,
  'fivestar_stars' => 5,
  'fivestar_labels_enable' => 1,
  'fivestar_label_0' => 'Cancel rating',
  'fivestar_label_1' => 'Poor',
  'fivestar_label_2' => 'Okay',
  'fivestar_label_3' => 'Good',
  'fivestar_label_4' => 'Great',
  'fivestar_label_5' => 'Awesome',
  'fivestar_label_6' => 'Give it @star/@count',
  'fivestar_label_7' => 'Give it @star/@count',
  'fivestar_label_8' => 'Give it @star/@count',
  'fivestar_label_9' => 'Give it @star/@count',
  'fivestar_label_10' => 'Give it @star/@count',
  'fivestar_style' => 'average',
  'fivestar_text' => 'dual',
  'fivestar_title' => 1,
  'fivestar_feedback' => 1,
  'fivestar_unvote' => 0,
  'fivestar_position_teaser' => 'hidden',
  'fivestar_position' => 'below',
  'fivestar_comment' => 0,
  'ant' => '0',
  'ant_pattern' => '',
  'ant_php' => 0,
);
$content['groups']  = array (
  0 => 
  array (
    'label' => 'Add images and video',
    'group_type' => 'standard',
    'settings' => 
    array (
      'form' => 
      array (
        'style' => 'fieldset',
        'description' => '',
      ),
      'display' => 
      array (
        'description' => '',
        'teaser' => 
        array (
          'format' => 'fieldset',
          'exclude' => 0,
        ),
        'full' => 
        array (
          'format' => 'fieldset',
          'exclude' => 0,
        ),
        4 => 
        array (
          'format' => 'fieldset',
          'exclude' => 0,
        ),
        2 => 
        array (
          'format' => 'fieldset',
          'exclude' => 0,
        ),
        3 => 
        array (
          'format' => 'fieldset',
          'exclude' => 0,
        ),
        'email_plain' => 
        array (
          'format' => 'fieldset',
          'exclude' => 0,
        ),
        'email_html' => 
        array (
          'format' => 'fieldset',
          'exclude' => 0,
        ),
        'token' => 
        array (
          'format' => 'fieldset',
          'exclude' => 0,
        ),
        'label' => 'above',
      ),
    ),
    'weight' => '1',
    'group_name' => 'group_media',
  ),
);
$content['extra']  = array (
  'title' => '-5',
  'body_field' => '-4',
  'menu' => '-1',
  'taxonomy' => '-3',
  'attachments' => '2',
  'shipping' => '0',
  'base' => '-2',
  'body' => '0',
);

And this is an export of the standard "story" content type with an imagefield added. This works fine:

$content['type']  = array (
  'name' => 'Artikel',
  'type' => 'story',
  'description' => 'En <em>artikel</em>, som minder om en <em>side</em>, gør det nemt at oprette og vise indhold, der informerer eller engagerer sitets besøgende. Pressemeddelelser, opslag og blog-lignende indlæg kan alle oprettes som <em>artikler</em>. Som standard vises <em>artikler</em> på sitets forside, og det er muligt for brugerne at skrive kommentarer.',
  'title_label' => 'Titel',
  'body_label' => 'Indhold',
  'min_word_count' => '0',
  'help' => '',
  'node_options' => 
  array (
    'status' => true,
    'promote' => true,
    'sticky' => false,
    'revision' => false,
  ),
  'language_content_type' => 0,
  'upload' => 1,
  'i18n_node' => 1,
  'i18nsync_nodeapi' => 
  array (
    'author' => false,
    'status' => false,
    'promote' => false,
    'moderate' => false,
    'sticky' => false,
    'revision' => false,
    'parent' => false,
    'taxonomy' => false,
    'comment' => false,
    'files' => false,
    'field_image' => false,
  ),
  'old_type' => 'story',
  'orig_type' => 'story',
  'module' => 'node',
  'custom' => '1',
  'modified' => '1',
  'locked' => '0',
  'og_content_type_usage' => 'omitted',
  'content_profile_use' => false,
  'comment' => 2,
  'comment_default_mode' => 4,
  'comment_default_order' => 1,
  'comment_default_per_page' => 50,
  'comment_controls' => 3,
  'comment_anonymous' => 0,
  'comment_subject_field' => 1,
  'comment_preview' => 1,
  'comment_form_location' => 0,
  'fivestar' => 0,
  'fivestar_stars' => 5,
  'fivestar_labels_enable' => 1,
  'fivestar_label_0' => 'Cancel rating',
  'fivestar_label_1' => 'Poor',
  'fivestar_label_2' => 'Okay',
  'fivestar_label_3' => 'Good',
  'fivestar_label_4' => 'Great',
  'fivestar_label_5' => 'Awesome',
  'fivestar_label_6' => 'Give it @star/@count',
  'fivestar_label_7' => 'Give it @star/@count',
  'fivestar_label_8' => 'Give it @star/@count',
  'fivestar_label_9' => 'Give it @star/@count',
  'fivestar_label_10' => 'Give it @star/@count',
  'fivestar_style' => 'average',
  'fivestar_text' => 'dual',
  'fivestar_title' => 1,
  'fivestar_feedback' => 1,
  'fivestar_unvote' => 0,
  'fivestar_position_teaser' => 'hidden',
  'fivestar_position' => 'below',
  'fivestar_comment' => 0,
  'ant' => 0,
  'ant_pattern' => '',
  'ant_php' => '',
);
$content['fields']  = array (
  0 => 
  array (
    'label' => 'Image',
    'field_name' => 'field_image',
    'type' => 'filefield',
    'widget_type' => 'imagefield_widget',
    'change' => 'Change basic information',
    'weight' => '31',
    'file_extensions' => 'jpg jpeg png gif',
    'file_path' => '',
    'max_filesize_per_file' => '',
    'max_filesize_per_node' => '',
    'max_resolution' => 0,
    'min_resolution' => 0,
    'custom_alt' => 0,
    'alt' => '',
    'custom_title' => 0,
    'title' => '',
    'description' => '',
    'group' => false,
    'required' => 0,
    'multiple' => '1',
    'list_field' => '0',
    'list_default' => 1,
    'description_field' => '0',
    'op' => 'Save field settings',
    'module' => 'filefield',
    'widget_module' => 'imagefield',
    'columns' => 
    array (
      'fid' => 
      array (
        'type' => 'int',
        'not null' => false,
      ),
      'list' => 
      array (
        'type' => 'int',
        'size' => 'tiny',
        'not null' => false,
      ),
      'data' => 
      array (
        'type' => 'text',
        'serialize' => true,
      ),
    ),
    'display_settings' => 
    array (
      'label' => 
      array (
        'format' => 'above',
        'exclude' => 0,
      ),
      'teaser' => 
      array (
        'format' => 'image_plain',
        'exclude' => 0,
      ),
      'full' => 
      array (
        'format' => 'image_plain',
        'exclude' => 0,
      ),
      4 => 
      array (
        'format' => 'image_plain',
        'exclude' => 0,
      ),
      2 => 
      array (
        'format' => 'image_plain',
        'exclude' => 0,
      ),
      3 => 
      array (
        'format' => 'image_plain',
        'exclude' => 0,
      ),
      'email_plain' => 
      array (
        'format' => 'image_plain',
        'exclude' => 0,
      ),
      'email_html' => 
      array (
        'format' => 'image_plain',
        'exclude' => 0,
      ),
      'token' => 
      array (
        'format' => 'image_plain',
        'exclude' => 0,
      ),
    ),
  ),
);
$content['extra']  = array (
  'title' => '-5',
  'body_field' => '0',
  'menu' => '-2',
  'attachments' => '30',
);

I hope this will help, thanks!

rsm08’s picture

Bump

Island Usurper’s picture

The "vareparti" type doesn't have any fields on it, it looks like. The "story" has $content['fields'], but "vareparti" doesn't. That would mean you can't upload pictures to that type of product at all.

rsm08’s picture

I didn't take a closer looks at those exports, but I can see what you mean. However this must be a problem with the export mechanism itself, because there IS indeed an imagefield on this content type. The field works fine (besides the mentioned problem in IE7).

Instead of going into why export isn't working, I copied the $form['field_image_cache'] from dprint_r() from the "node/add/vareparti" url. As you can see, the field is there:

 [field_image_cache] => Array
        (
            [#theme] => content_multiple_values
            [#title] => Billede
            [#required] => 0
            [#description] => 
            [0] => Array
                (
                    [#title] => 
                    [#type] => imagefield_widget
                    [#default_value] => Array
                        (
                            [fid] => 0
                            [list] => 1
                            [data] => Array
                                (
                                    [description] => 
                                )

                            [alt] => 
                            [title] => 
                        )

                    [#upload_validators] => Array
                        (
                            [filefield_validate_associate_field] => Array
                                (
                                    [0] => Array
                                        (
                                            [field_name] => field_image_cache
                                            [type_name] => vareparti
                                            [display_settings] => Array
                                                (
                                                    [label] => Array
                                                        (
                                                            [format] => hidden
                                                        )

                                                    [teaser] => Array
                                                        (
                                                            [format] => hidden
                                                        )

                                                    [full] => Array
                                                        (
                                                            [format] => hidden
                                                        )

                                                    [4] => Array
                                                        (
                                                            [format] => hidden
                                                        )

                                                )

                                            [widget_active] => 1
                                            [type] => filefield
                                            [required] => 0
                                            [multiple] => 1
                                            [db_storage] => 0
                                            [module] => filefield
                                            [active] => 1
                                            [locked] => 0
                                            [columns] => Array
                                                (
                                                    [fid] => Array
                                                        (
                                                            [type] => int
                                                            [not null] => 
                                                        )

                                                    [list] => Array
                                                        (
                                                            [type] => int
                                                            [size] => tiny
                                                            [not null] => 
                                                        )

                                                    [data] => Array
                                                        (
                                                            [type] => text
                                                            [serialize] => 1
                                                        )

                                                )

                                            [list_field] => 0
                                            [list_default] => 1
                                            [description_field] => 0
                                            [widget] => Array
                                                (
                                                    [file_extensions] => gif jpg jpeg png bmp
                                                    [file_path] => 
                                                    [max_filesize_per_file] => 
                                                    [max_filesize_per_node] => 
                                                    [file_widgets] => 
                                                    [max_resolution] => 0
                                                    [min_resolution] => 0
                                                    [alt] => 
                                                    [custom_alt] => 1
                                                    [title] => 
                                                    [custom_title] => 1
                                                    [collapsible] => 2
                                                    [resolution] => 640x480
                                                    [enforce_ratio] => 0
                                                    [croparea] => 600x0
                                                    [always_show] => 0
                                                    [label] => Image
                                                    [weight] => -1
                                                    [description] => 
                                                    [type] => imagefield_widget
                                                    [module] => imagefield
                                                )

                                        )

                                )

                            [filefield_validate_size] => Array
                                (
                                    [0] => 83886080
                                )

                            [filefield_validate_extensions] => Array
                                (
                                    [0] => gif jpg jpeg png
                                )

                            [filefield_validate_is_image] => Array
                                (
                                )

                        )

                    [_weight] => Array
                        (
                            [#type] => weight
                            [#delta] => 0
                            [#default_value] => 0
                            [#weight] => 100
                        )

                    [#description] => 
                    [#required] => 
                    [#weight] => 0
                    [#delta] => 0
                    [#columns] => Array
                        (
                            [0] => fid
                            [1] => list
                            [2] => data
                        )

                    [#field_name] => field_image_cache
                    [#type_name] => vareparti
                )

            [field_image_cache_add_more] => Array
                (
                    [#type] => submit
                    [#name] => field_image_cache_add_more
                    [#value] => Add another item
                    [#weight] => 0
                    [#submit] => Array
                        (
                            [0] => content_add_more_submit_proxy
                        )

                    [#ahah] => Array
                        (
                            [path] => content/js_add_more/vareparti/field_image_cache
                            [wrapper] => field-image-cache-items
                            [method] => replace
                            [effect] => fade
                        )

                    [#field_name] => field_image_cache
                    [#type_name] => vareparti
                    [#prefix] => <div class="content-add-more clear-block">
                    [#suffix] => </div>
                )

            [#prefix] => <div id="field-image-cache-items">
            [#suffix] => </div>
            [#field_name] => field_image_cache
            [#tree] => 1
            [#weight] => -1
            [#access] => 1
            [#count] => 8
        )

For comparative purposes, I did the same thing with "node/add/story" where the imagefield is working fine:

    [field_image] => Array
        (
            [#theme] => content_multiple_values
            [#title] => Billede
            [#required] => 0
            [#description] => 
            [0] => Array
                (
                    [#title] => 
                    [#type] => imagefield_widget
                    [#default_value] => Array
                        (
                            [fid] => 0
                            [list] => 1
                            [data] => Array
                                (
                                    [description] => 
                                )

                            [alt] => 
                            [title] => 
                        )

                    [#upload_validators] => Array
                        (
                            [filefield_validate_associate_field] => Array
                                (
                                    [0] => Array
                                        (
                                            [field_name] => field_image
                                            [type_name] => story
                                            [display_settings] => Array
                                                (
                                                    [label] => Array
                                                        (
                                                            [format] => above
                                                            [exclude] => 0
                                                        )

                                                    [teaser] => Array
                                                        (
                                                            [format] => image_plain
                                                            [exclude] => 0
                                                        )

                                                    [full] => Array
                                                        (
                                                            [format] => image_plain
                                                            [exclude] => 0
                                                        )

                                                    [4] => Array
                                                        (
                                                            [format] => image_plain
                                                            [exclude] => 0
                                                        )

                                                    [2] => Array
                                                        (
                                                            [format] => image_plain
                                                            [exclude] => 0
                                                        )

                                                    [3] => Array
                                                        (
                                                            [format] => image_plain
                                                            [exclude] => 0
                                                        )

                                                    [email_plain] => Array
                                                        (
                                                            [format] => image_plain
                                                            [exclude] => 0
                                                        )

                                                    [email_html] => Array
                                                        (
                                                            [format] => image_plain
                                                            [exclude] => 0
                                                        )

                                                    [token] => Array
                                                        (
                                                            [format] => image_plain
                                                            [exclude] => 0
                                                        )

                                                )

                                            [widget_active] => 1
                                            [type] => filefield
                                            [required] => 0
                                            [multiple] => 1
                                            [db_storage] => 0
                                            [module] => filefield
                                            [active] => 1
                                            [locked] => 0
                                            [columns] => Array
                                                (
                                                    [fid] => Array
                                                        (
                                                            [type] => int
                                                            [not null] => 
                                                        )

                                                    [list] => Array
                                                        (
                                                            [type] => int
                                                            [size] => tiny
                                                            [not null] => 
                                                        )

                                                    [data] => Array
                                                        (
                                                            [type] => text
                                                            [serialize] => 1
                                                        )

                                                )

                                            [list_field] => 0
                                            [list_default] => 1
                                            [description_field] => 0
                                            [widget] => Array
                                                (
                                                    [file_extensions] => jpg jpeg png gif
                                                    [file_path] => 
                                                    [max_filesize_per_file] => 
                                                    [max_filesize_per_node] => 
                                                    [file_widgets] => 
                                                    [max_resolution] => 0
                                                    [min_resolution] => 0
                                                    [alt] => 
                                                    [custom_alt] => 0
                                                    [title] => 
                                                    [custom_title] => 0
                                                    [label] => Image
                                                    [weight] => 31
                                                    [description] => 
                                                    [type] => imagefield_widget
                                                    [module] => imagefield
                                                )

                                        )

                                )

                            [filefield_validate_size] => Array
                                (
                                    [0] => 83886080
                                )

                            [filefield_validate_extensions] => Array
                                (
                                    [0] => jpg jpeg png gif
                                )

                            [filefield_validate_is_image] => Array
                                (
                                )

                        )

                    [_weight] => Array
                        (
                            [#type] => weight
                            [#delta] => 0
                            [#default_value] => 0
                            [#weight] => 100
                        )

                    [#description] => 
                    [#required] => 
                    [#weight] => 0
                    [#delta] => 0
                    [#columns] => Array
                        (
                            [0] => fid
                            [1] => list
                            [2] => data
                        )

                    [#field_name] => field_image
                    [#type_name] => story
                )

            [field_image_add_more] => Array
                (
                    [#type] => submit
                    [#name] => field_image_add_more
                    [#value] => Add another item
                    [#weight] => 32
                    [#submit] => Array
                        (
                            [0] => content_add_more_submit_proxy
                        )

                    [#ahah] => Array
                        (
                            [path] => content/js_add_more/story/field_image
                            [wrapper] => field-image-items
                            [method] => replace
                            [effect] => fade
                        )

                    [#field_name] => field_image
                    [#type_name] => story
                    [#prefix] => <div class="content-add-more clear-block">
                    [#suffix] => </div>
                )

            [#prefix] => <div id="field-image-items">
            [#suffix] => </div>
            [#field_name] => field_image
            [#tree] => 1
            [#weight] => 31
            [#access] => 1
            [#count] => 8
        )

I hope that these data can give you some clues!

rsm08’s picture

Bump

rsm08’s picture

Bump

Island Usurper’s picture

They look the same to me. All I can figure is that it's a weird bug in IE. You might try removing the image field from your product types and adding it back again, but that can cause you to lose all of your images.

rsm08’s picture

I don't think removing the field and adding it again will do anything. Since it's a javascript problem, it must be caused by some DOM detail, where IE acts differently than it should. As we all know, debugging javascript in IE is a pain. I don't even have a debugger installed, so I'll have to go find one.

It must be something with the field's naming or placement in the DOM when it's a ubercart image in contrary to when it's just a regular filefield.

Maybe you can give me a clue as to what the difference is between the ubercart field_image_cache and a normal filefield, when displayed on the edit page?!

If I can't solve this, I'm gonna just change imagecache, so it adds a new field automatically after each upload instead of the current interface.

petr illek’s picture

I have similar problem. In IE the field just disapear, but in FF i got the message:
Error occured.
/content/js_add_more/XXX
(no more information availaible)

Where XXX is the name of field.

Im suffering from this not only in product nodes, but in every content where I have the "add another item"

Any ideas what to do?

keesje’s picture

keesje’s picture

Version: 6.x-2.0-beta5 » 6.x-2.0-rc1

Still applies 2.0 rc1.
FF3 works without warning.

I have IE7 + JS debugger, but no JS warning what so ever. Might be the debugger not debugging AJAX transactions ;).

rsm08’s picture

It wasn't exactly the same problem as the thread you quoted. In there the problem had to do with deletion of images. My problem was, that whenever I clicked the "Add another item" button, the whole filefiled would just disappear (javascript caused).

The problem was only in IE7 though - not FF.

What happened was, that suddenly it just worked, and now I can't reproduce the error anymore. I don't know if it will return, so I haven't gotten my hopes up yet. It could be all sorts of other modules interfering, so maybe I've removed some module that was messing this up. But I can't know for sure, and particularly not which module it was.

Debugging Drupal is sometimes like a game of mastermind with all those modules!

Island Usurper’s picture

Status: Active » Postponed (maintainer needs more info)

Since this is also an IE problem, I suspect that the same fix will work for both issues. Try applying the patch at #404234-28: Ajax bug on upload/delete Ubercart images and see if it helps.

tr’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

According to #18 the OP no longer has the problem, and according to #19 this seems to have been fixed by #404234: Ajax bug on upload/delete Ubercart images. Since neither the OP nor anyone else has reported a problem in the 8 months since the fix, I'm going to consider this solved and close the issue.