Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 44.
I have a taxonomy field with a vocabulary that does not allow "tags". So when the code hits that line of code:
foreach ($form_taxonomy['taxonomy']['tags'] as $key => $value) {
The tags attribute hasn't been set so it prints the warning.
Adding if (is_array($form_taxonomy['taxonomy']['tags']))
before the for loop fixes the issue.
if (is_array($form_taxonomy['taxonomy']['tags'])) {
foreach ($form_taxonomy['taxonomy']['tags'] as $key => $value) {
// taxonomy tags
if (!in_array($key, $fields_preview_list['taxonomy'])) {
unset($form_taxonomy['taxonomy']['tags'][$key]);
}
}
}
Comment | File | Size | Author |
---|---|---|---|
#1 | imagefield_conditional_tags_535160.patch | 1.57 KB | hadsie |
Comments
Comment #1
hadsie CreditAttribution: hadsie commentedhere's a patch for this one.
Comment #2
grandcat CreditAttribution: grandcat commentedThank you for the patch file, I'll check this.
Comment #3
grandcat CreditAttribution: grandcat commentedCommitted to HEAD. Thanks.
Comment #5
shiva7663 CreditAttribution: shiva7663 commentedThe patch failed for me: "can't find file to patch at input line 8"
Comment #6
grandcat CreditAttribution: grandcat commentedThen just use the dev branch.
Comment #7
shiva7663 CreditAttribution: shiva7663 commentedAll right, and may Ghu have mercy on my soul....