--- img_assist.module.org	2007-09-14 22:43:50.745458000 +0200
+++ img_assist.module	2007-09-15 05:40:47.287781900 +0200
@@ -650,21 +650,25 @@ function img_assist_thumbs() {
 
     if ($tid) { // show by term ID
       if (user_access('access all images')) { // for this term, show ALL published images + the USER's unpublished images
-        $query = "SELECT n.nid FROM {node} n, {term_node} t WHERE t.nid=n.nid AND n.type='image' AND t.tid = %d AND (n.uid = %d OR n.status = 1) ORDER BY n.sticky DESC, n.created DESC";
+        // Imagefield test 15/09/2007 sun
+        $query = "SELECT n.nid FROM {node} n, {term_node} t WHERE t.nid=n.nid AND t.tid = %d AND (n.uid = %d OR n.status = 1) ORDER BY n.sticky DESC, n.created DESC";
         $params = array($tid, $user->uid);
       }
       else { // for this term, show only the user's images
-        $query = "SELECT n.nid FROM {node} n, {term_node} t WHERE t.nid=n.nid AND n.type='image' AND t.tid = %d AND n.uid = %d ORDER BY n.sticky DESC, n.created DESC";
+        // Imagefield test 15/09/2007 sun
+        $query = "SELECT n.nid FROM {node} n, {term_node} t WHERE t.nid=n.nid AND t.tid = %d AND n.uid = %d ORDER BY n.sticky DESC, n.created DESC";
         $params = array($tid, $user->uid);
       }
     }
     else {
        if (user_access('access all images') && (!$myimagesonly)) { // show ALL published images + the USER's unpublished images
-        $query = "SELECT n.nid FROM {node} n WHERE n.type='image' AND (n.uid = %d OR n.status = 1) ORDER BY n.sticky DESC, n.created DESC";
+        // Imagefield test 15/09/2007 sun
+        $query = "SELECT n.nid FROM {node} n WHERE (n.uid = %d OR n.status = 1) ORDER BY n.sticky DESC, n.created DESC";
         $params = array($user->uid);
       }
       else { // default condition: show only the user's images
-        $query = "SELECT n.nid FROM {node} n WHERE n.type='image' AND n.uid= %d ORDER BY n.sticky DESC, n.created DESC";
+        // Imagefield test 15/09/2007 sun
+        $query = "SELECT n.nid FROM {node} n WHERE n.uid= %d ORDER BY n.sticky DESC, n.created DESC";
         $params = array($user->uid);
       }
     }
@@ -712,10 +716,17 @@ function img_assist_properties() {
     $node = node_load(array('nid' => $nid));
 
     // Setup a default caption & description
-    $node->title = str_replace("\r", ' ', strip_tags($node->title));
-    $node->title = str_replace("\n", ' ', trim($node->title));
-    $node->body = str_replace("\r", ' ', strip_tags($node->body));
-    $node->body = str_replace("\n", ' ', trim($node->body));
+    // Imagefield test 15/09/2007 sun
+    if (isset($node->field_image[0])) {
+      $node->title = $node->field_image[0]['title'];
+      $node->body = $node->field_image[0]['alt'];
+    }
+    else {
+      $node->title = str_replace("\r", ' ', strip_tags($node->title));
+      $node->title = str_replace("\n", ' ', trim($node->title));
+      $node->body = str_replace("\r", ' ', strip_tags($node->body));
+      $node->body = str_replace("\n", ' ', trim($node->body));
+    }
 
     $output = drupal_get_form('img_assist_properties_form', $node, $update);
   }
@@ -1062,6 +1073,9 @@ function img_assist_display(&$node, $siz
   else {
     if (is_array($size)) {
       $info = image_get_info(file_create_path($node->images[$label]));
+      if (isset($node->field_image[0])) {
+        $info = image_get_info(file_create_path($node->field_image[0]['filepath']));
+      }
       if (($info['width'] != $size['width']) && ($info['height'] != $size['height'])) {
         $regen = true;
       }
@@ -1073,14 +1087,26 @@ function img_assist_display(&$node, $siz
   }
 
   if (empty($node->images[$label])) {
-    return;
+    // What's that? 15/09/2007 sun
+    // return;
   }
 
-  $info = image_get_info(file_create_path($node->images[$label])); // get actual size ($size is just a bounding box)
+  // get actual size ($size is just a bounding box)
+  $info = image_get_info(file_create_path($node->images[$label]));
+  if (isset($node->field_image[0])) {
+    $info = image_get_info(file_create_path($node->field_image[0]['filepath']));
+  }
+  
   $attributes['class'] = "image image-$label". (isset($attributes['class']) ? " ". $attributes['class'] : "");
   $attributes['width'] = $info['width'];
   $attributes['height'] = $info['height'];
-  return theme('image_display', $node, $label, file_create_url($node->images[$label]), $attributes);
+  if (isset($node->field_image[0])) {
+    $output = theme('image_display', $node, $label, file_create_url($node->field_image[0]['filepath']), $attributes);
+  }
+  else {
+    $output = theme('image_display', $node, $label, file_create_url($node->images[$label]), $attributes);
+  }
+  return $output;
   //return theme('image_display', file_create_url($node->images[$label]), $node->title, $node->title, $attr, false);
 }
 
@@ -1094,6 +1120,11 @@ function _img_assist_build_derivatives(&
     return false;
   }
   $info = image_get_info(file_create_path($node->images[IMAGE_ORIGINAL]));
+  // Imagefield test 15/09/2007 sun
+  if ($node->field_image) {
+    $info = image_get_info(file_create_path($node->field_image[0]['filepath']));
+    $imagefield = TRUE;
+  }
 
   if (is_array($size) && !empty($size['key']) && !empty($size['width']) && !empty($size['height'])) { // custom size
       $sizes = array($size['key'] => $size);
@@ -1116,6 +1147,10 @@ function _img_assist_build_derivatives(&
     if (is_array($size) && ($size['label']) && ($size['width']) && ($size['height'])) {
       if ($info['width'] > $size['width'] || $info['height'] > $size['height']) {
         $source = file_create_path($node->images[IMAGE_ORIGINAL]);
+        // Imagefield test 15/09/2007 sun
+        if ($imagefield) {
+          $source = file_create_path($node->field_image[0]['filepath']);
+        }
         $destination = _image_filename(basename($source), $key, FALSE);
         if (!image_scale($source, file_create_path($destination), $size['width'], $size['height'])) {
           drupal_set_message(t('Unable to create %label image', array('%label' => $size['label'])), 'error');
