--- image_attach.module	Fri Mar  2 18:22:54 2007
+++ image_attach.module.user	Fri Mar  2 19:25:33 2007
@@ -51,6 +51,14 @@ function image_attach_admin_settings() {
     '#description' => t('When enabled, will allow existing image nodes to be attached instead of uploading new images.')
   );
 
+  $form['image_attach_limit_user'] = array(
+    '#type' => 'radios',
+    '#title' => t('Limit images to current user'),
+    '#default_value' => variable_get('image_attach_limit_user', 0),
+    '#options' => array(0 => 'Disabled', 1 => 'Enabled'),
+    '#description' => t('When enabled, will only list images from the current user.')
+  );
+
   return system_settings_form($form);
 }
 
@@ -193,7 +201,16 @@ function image_attach_nodeapi(&$node, $o
  */
 function _image_attach_get_image_nodes() {
   $rows = array(0 => '');
-  $result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.status=1 AND type='image' ORDER BY n.sticky DESC, n.title ASC"));
+  global $user;
+  if (variable_get('image_attach_limit_user', 0)) {
+    $where = "type='image' AND n.uid=". $user->uid;
+  }
+  else {
+    $where = "n.status=1 AND type='image'";
+  }
+
+  $result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE ". $where . " ORDER BY n.sticky DESC, n.title ASC"));
+
   if (db_num_rows($result) == 0) {
       return array();
   }
