I'm getting a php warning when uploading images using the imagefield single image per node method. The exact error is:
warning: Invalid argument supplied for foreach() in .../sites/all/modules/image_fupload/includes/images.previewlist.imagefield.inc on line 38.
Similar to issue http://drupal.org/node/535160
I am not good programmer, but I did simmilar thing as in issue mentioned above.
Original:

    // delete all elements without the ones we need
    foreach ($form_taxonomy['taxonomy'] as $key => $value) {
      // taxonomy normal
      if (!in_array($key, $fields_preview_list['taxonomy']) && is_numeric($key)) {
        unset($form_taxonomy['taxonomy'][$key]);
      }
    }

New:

    // delete all elements without the ones we need
    if (is_array($form_taxonomy['taxonomy'])) {
    foreach ($form_taxonomy['taxonomy'] as $key => $value) {
      // taxonomy normal
      if (!in_array($key, $fields_preview_list['taxonomy']) && is_numeric($key)) {
        unset($form_taxonomy['taxonomy'][$key]);
      }
    }
  }

Sorry but don't know how to make patch or check if it is ok. But warning is gone
Please can someone review it?

Thanks

Comments

agir’s picture

Title: Invalid argument supplied for foreach() in ... images.previewlist.imagefield.inc on line 44 » Invalid argument supplied for foreach() in ... images.previewlist.imagefield.inc on line 38