Index: contrib/image_attach/image_attach_views_handler_field_attached_images.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_attach/image_attach_views_handler_field_attached_images.inc,v retrieving revision 1.2 diff -u -p -r1.2 image_attach_views_handler_field_attached_images.inc --- contrib/image_attach/image_attach_views_handler_field_attached_images.inc 5 Sep 2009 15:33:18 -0000 1.2 +++ contrib/image_attach/image_attach_views_handler_field_attached_images.inc 1 Oct 2009 10:41:24 -0000 @@ -62,6 +62,7 @@ class image_attach_views_handler_field_a * multiple fields. */ function pre_render(&$values) { + $nids = array(); foreach ($values as $v) { if (isset($v->{$this->aliases['image_attach_nid']})) { // Make the nid safe. @@ -70,17 +71,20 @@ class image_attach_views_handler_field_a $nids[$nid] = $nid; } } - $nids_string = implode(',', $nids); - $result = db_query("SELECT nid, iid FROM {image_attach} WHERE nid IN (" . $nids_string . ") ORDER BY weight"); - while ($data = db_fetch_object($result)) { - // Store all the attached image nids (iid) keyed by attaching nid. - $attached_images[$data->nid][] = $data->iid; - } - // Place the data into the $values array for each result. - foreach ($values as $id => $v) { - if (isset($attached_images[$v->{$this->aliases['image_attach_nid']}])) { - $values[$id]->image_attach_iids = $attached_images[$v->{$this->aliases['image_attach_nid']}]; + if (count($nids)) { + $nids_string = implode(',', $nids); + $result = db_query("SELECT nid, iid FROM {image_attach} WHERE nid IN (" . $nids_string . ") ORDER BY weight"); + while ($data = db_fetch_object($result)) { + // Store all the attached image nids (iid) keyed by attaching nid. + $attached_images[$data->nid][] = $data->iid; + } + + // Place the data into the $values array for each result. + foreach ($values as $id => $v) { + if (isset($attached_images[$v->{$this->aliases['image_attach_nid']}])) { + $values[$id]->image_attach_iids = $attached_images[$v->{$this->aliases['image_attach_nid']}]; + } } } }