Index: image_attach.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_attach/image_attach.module,v
retrieving revision 1.9.2.4
diff -u -p -r1.9.2.4 image_attach.module
--- image_attach.module	1 Mar 2007 03:52:43 -0000	1.9.2.4
+++ image_attach.module	21 Mar 2007 20:02:57 -0000
@@ -58,6 +58,7 @@ function image_attach_admin_settings() {
  * implementation of hook_form_alter()
  */
 function image_attach_form_alter($form_id, &$form) {
+  // Content type settings form.
   if ($form_id == 'node_type_form' && $form['#node_type']->type != 'image') {
     _image_check_settings();
     $form['workflow']['image_attach'] = array(
@@ -66,15 +67,27 @@ function image_attach_form_alter($form_i
       '#default_value' => variable_get('image_attach_'. $form['#node_type']->type, 0),
       '#options' => array(0 => t('Disabled'), 1 => t('Enabled')),
       '#description' => t('Should this node allows users to upload an image?'),
-      );
+    );
+    $form['workflow']['image_attach_weight_teaser'] = array(
+      '#type' => 'weight',
+      '#title' => t('Attached image teaser weight'),
+      '#default_value' => variable_get('image_attach_weight_teaser_'. $form['#node_type']->type, 0),
+      '#description' => t("This value determines the image's weight in the teaser."),
+    );
+    $form['workflow']['image_attach_weight_body'] = array(
+      '#type' => 'weight',
+      '#title' => t('Attached image body weight'),
+      '#default_value' => variable_get('image_attach_weight_body_'. $form['#node_type']->type, 0),
+      '#description' => t("This value determines the image's weight in the body."),
+    );
   }
+  // Node edit form.
   else if (isset($form['type']) && $form['type']['#value'] != 'image') {
     $type = $form['type']['#value'];
     // if enabled adjust the form
     if ($form_id == $type .'_node_form' && variable_get('image_attach_'. $type, 0)) {
       $node = $form['#node'];
       _image_check_settings();
-      $existing = variable_get('image_attach_existing', 1);
       $value = ($node->new_image) ? '#value' : '#default_value';
       $form['#attributes'] = array("enctype" => "multipart/form-data");
       
@@ -92,7 +105,7 @@ function image_attach_form_alter($form_i
           '#value' => image_display($image, 'thumbnail')
           );
       }
-      if ($existing && user_access('access content')) {         
+      if (variable_get('image_attach_existing', 1) && user_access('access content')) {         
         $form['image_attach']['iid'] = array(
           '#type' => 'select', 
           '#title' => t('Existing Image'), 
@@ -105,7 +118,7 @@ function image_attach_form_alter($form_i
           '#value' => t('-or-'),
           '#attributes' => array('class' => 'either-choice')
           );
-        }
+      }
       else {
         $form['image_attach']['iid'] = array(
           '#type' => 'hidden',
@@ -157,6 +170,7 @@ function image_attach_nodeapi(&$node, $o
         $node->iid = $_POST['iid'];
       }
       break;
+
     case 'insert':
     case 'update':
       if ($node->iid) {
@@ -164,25 +178,28 @@ function image_attach_nodeapi(&$node, $o
         db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $node->iid);
       }
       break;
+
     case 'delete':
       db_query("DELETE FROM {image_attach} WHERE nid=%d", $node->nid);
       break;
+
     case 'load':
       $iid = db_result(db_query("SELECT iid FROM {image_attach} WHERE nid=%d", $node->nid));
       return array('iid' => $iid);
      
-    // Pass the body and teaser objects to the theme again to add the images
     case 'view':
       if($node->iid && function_exists('image_display')){
         if ($teaser) {
           $node->content['image_attach'] = array(
-            '#value' => theme('image_attach_teaser', $node)
-            );
+            '#value' => theme('image_attach_teaser', $node),
+            '#weight' => variable_get('image_attach_weight_teaser_'. $node->type, 0) 
+          );
         }
         else {
           $node->content['image_attach'] = array(
-            '#value' => theme('image_attach_body', $node)
-            );
+            '#value' => theme('image_attach_body', $node),
+            '#weight' => variable_get('image_attach_weight_body_'. $node->type, 0) 
+          );
         }
       }
   }
@@ -307,8 +324,7 @@ function theme_image_attach_teaser($node
   $image = node_load($node->iid);
 
   $info = image_get_info(file_create_path($image->images['thumbnail']));
-  $output = '';
-  $output .= '<div style="width: '. $info['width'] .'px" class="image-attach-teaser">';
+  $output = '<div style="width: '. $info['width'] .'px" class="image-attach-teaser">';
   $output .= l(image_display($image, 'thumbnail'), "node/$node->nid", array(), NULL, NULL, FALSE, TRUE);
   $output .= '</div>'."\n";
   return $output;
@@ -323,8 +339,7 @@ function theme_image_attach_body($node){
   $image = node_load($node->iid);
   
   $info = image_get_info(file_create_path($image->images['thumbnail']));
-  $output = '';
-  $output .= '<div style="width: '. $info['width'] .'px" class="image-attach-body">';
+  $output = '<div style="width: '. $info['width'] .'px" class="image-attach-body">';
   $output .= l(image_display($image, 'thumbnail'), "node/$node->nid", array(), NULL, NULL, FALSE, TRUE);
   $output .= '</div>'."\n";
   return $output;
