Index: contrib/image_attach/image_attach.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_attach/image_attach.module,v
retrieving revision 1.17
diff -u -r1.17 image_attach.module
--- contrib/image_attach/image_attach.module	30 Mar 2007 16:27:38 -0000	1.17
+++ contrib/image_attach/image_attach.module	1 Apr 2007 22:28:23 -0000
@@ -58,23 +58,41 @@
  * 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(
+      '#type' => 'fieldset',
+      '#title' => t('Attach Images'),
+      '#tree' => FALSE,
+    );
+    $form['workflow']['image_attach']['enabled'] = array(
       '#type' => 'radios',
       '#title' => t('Attach Images'),
       '#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 +110,7 @@
           '#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 +123,7 @@
           '#value' => t('-or-'),
           '#attributes' => array('class' => 'either-choice')
           );
-        }
+      }
       else {
         $form['image_attach']['iid'] = array(
           '#type' => 'hidden',
@@ -185,8 +203,10 @@
     // Pass the body and teaser objects to the theme again to add the images
     case 'view':
       if ($node->iid && function_exists('image_display')) {
+        $teaser_or_body = $teaser ? 'teaser' : 'body';
         $node->content['image_attach'] = array(
-          '#value' => theme($teaser ? 'image_attach_teaser' : 'image_attach_body', $node)
+          '#value' => theme("image_attach_{$teaser_or_body}", $node),
+          '#weight' => variable_get("image_attach_weight_{$teaser_or_body}_{$node->type}", 0),
         );
       }
       break;

