I've done a print_r($node), and while my image shows up, the associated term_name $node->image['term_name'] does not exist, even though it has been specifically set in the content edit. The placeholder term_name is in the array, but the value is blank.

Comments

smanes’s picture

I encountered the same thing. The Category pulldown is getting populated with the wrong tids (in my case, 2 and 3 when it should be 79 and 80). As a result, term_name winds up blank in the node aggregate.

In function _image_upload_form() , there's an array_merge which is clobbering the tids:

$terms = array_merge($terms, _image_upload_form_get_terms($node->type));

_image_upload_form_get_terms() actually returns this:

Array
(
    [76] => Default
    [80] => image_homepage
    [79] => image_minibanner
)

But after the array_merge to prepend the "Please Select" prompt, the array looks like this:

Array
(
    [0] => Please Select
    [1] => Default
    [2] => image_homepage
    [3] => image_minibanner
)

The select value is then assigned:

$form['images'][$key]['tid'] = array('#type' => 'select', '#default_value' => $file->tid, '#options' => $terms);

Except that's not a tid but a row enumeration in the array.

The PHP array_merge() function has an unexpected side-effect.: it renumbers numeric keys. So I changed...

$terms = array('Please Select');
$terms = array_merge($terms, _image_upload_form_get_terms($node->type));

to...

$terms = array('Please Select');
$terms += _image_upload_form_get_terms($node->type);

and I got the pulldown I expected:

Array
(
    [0] => Please Select
    [76] => Default
    [80] => image_homepage
    [79] => image_minibanner
)
bojanz’s picture

Status: Active » Fixed

Thanks for the fix, will issue a new version right away.

Status: Fixed » Closed (fixed)

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