Index: imagefield.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.css,v
retrieving revision 1.2.4.1
diff -u -r1.2.4.1 imagefield.css
--- imagefield.css	17 Dec 2007 04:47:05 -0000	1.2.4.1
+++ imagefield.css	14 Apr 2008 06:09:16 -0000
@@ -8,7 +8,7 @@
   border: 1px solid #e5e5e5;
 }
 
-div.imagefield-edit-preview  {
+div.imagefield-edit-preview {
   float: left;
 }
 
@@ -26,7 +26,6 @@
 }
 
 div.imagefield-edit-image-flags div.form-item {
-	float: right;
+  float: right;
 }
 
-
Index: imagefield.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.module,v
retrieving revision 1.30.2.6.2.49
diff -u -r1.30.2.6.2.49 imagefield.module
--- imagefield.module	2 Apr 2008 16:06:00 -0000	1.30.2.6.2.49
+++ imagefield.module	14 Apr 2008 06:09:17 -0000
@@ -4,12 +4,14 @@
 /**
  * @file
  * Defines an image field type.
- * imagefield uses content.module to store the fid, and the drupal files 
+ * imagefield uses content.module to store the fid, and the drupal files
  * table to store the actual file data.
  *
  */
 
-
+/**
+ * Implementation of hook_menu().
+ */
 function imagefield_menu($maycache) {
   $items = array();
   if ($maycache) {
@@ -22,23 +24,23 @@
     );
   }
   elseif ($_SESSION['imagefield']) {
-    // do this variable_get once.... 
+    // do this variable_get once....
     $download_method = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC);
 
-    // Iterate over each field stored in session imagefield looking 
+    // Iterate over each field stored in session imagefield looking
     // for files in a preview state to add menu items for. This
     // allows us to preview new uploads before a node is submitted.
     foreach ($_SESSION['imagefield'] as $fieldname => $files) {
       // move on to the next field if there is nothing to process in files.
       if (empty($files)) continue;
 
-      foreach($files as $delta => $file) {
+      foreach ($files as $delta => $file) {
         // If the file is not a preview do not display it.
         if (empty($file['preview']))  continue;
-    
+
         // filepath to pass into _imagefield_preview
         $filepath = $file['preview'];
-        
+
         // build url path for private files menu item.
         if ($download_method == FILE_DOWNLOADS_PRIVATE) {
           // strip out the file_directory_path. It shouldn't be a part
@@ -46,7 +48,7 @@
           if (strpos($file['preview'], file_directory_path()) !== FALSE) {
             $file['preview'] = trim(substr($file['preview'], strlen(file_directory_path())), '\\/');
           }
-          $file['preview'] = 'system/files/' . $file['preview'];
+          $file['preview'] = 'system/files/'. $file['preview'];
         }
 
         $items[] = array(
@@ -63,7 +65,8 @@
 }
 
 /**
- *  transfer a file that is in a 'preview' state.
+ *  Transfer a file that is in a 'preview' state.
+ *
  *  @todo  multiple support
  */
 function _imagefield_preview($filepath) {
@@ -76,7 +79,7 @@
         // headers set in drupal_page_header().
         $modified_time = filemtime($file['filepath']);
         $last_modified = gmdate('D, d M Y H:i:s', $modified_time) .' GMT';
-        $etag = '"'.md5($last_modified).'"';
+        $etag = '"'. md5($last_modified) .'"';
 
         file_transfer($file['filepath'], array(
           'Content-Type: '. mime_header_encode($file['filemime']),
@@ -91,6 +94,9 @@
   }
 }
 
+/**
+ * Implementation of hook_perm().
+ */
 function imagefield_perm() {
   return array('view imagefield uploads');
 }
@@ -152,7 +158,7 @@
           form_set_value(array('#parents' => array('default_image')), (array) $file);
         }
       }
- 
+
       break;
     case 'save':
       return array('default_image', 'use_default_image');
@@ -160,8 +166,8 @@
     case 'database columns':
       $columns = array(
         'fid' => array('type' => 'int', 'not null' => TRUE, 'default' => '0'),
-        'title' => array('type' => 'varchar', length => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
-        'alt' => array('type' => 'varchar', length => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
+        'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
+        'alt' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
       );
       return $columns;
 
@@ -178,7 +184,7 @@
 }
 
 /**
- * Custom filter for imagefield NOT NULL
+ * Custom filter for imagefield NOT NULL.
  */
 function imagefield_views_handler_filter_is_not_null($op, $filter, $filterinfo, &$query) {
   if ($op == 'handler') {
@@ -203,12 +209,12 @@
 }
 
 /**
- * insert a file into the database.
+ * Insert a file into the database.
+ *
  * @param $node
- *    node object file will be associated with.
+ *    Node object this file is be associated with.
  * @param $file
- *    file to be inserted, passed by reference since fid should be attached.
- *    
+ *    File to be inserted, passed by reference since fid should be attached.
  */
 function imagefield_file_insert($node, &$file, $field) {
   $fieldname = $field['field_name'];
@@ -216,13 +222,13 @@
   // allow tokenized paths.
   if (function_exists('token_replace')) {
     global $user;
-    $widget_image_path = token_replace($field['widget']['image_path'],'user', $user);
+    $widget_image_path = token_replace($field['widget']['image_path'], 'user', $user);
   }
   else {
     $widget_image_path = $field['widget']['image_path'];
   }
- 
-  $filepath = file_create_path($widget_image_path) . '/' . $file['filename'];
+
+  $filepath = file_create_path($widget_image_path) .'/'. $file['filename'];
 
   if (imagefield_check_directory($widget_image_path) && $file = file_save_upload((object)$file, $filepath)) {
     $file = (array)$file;
@@ -240,26 +246,29 @@
   }
 }
 
-
 /**
- * update the file record if necessary
+ * Update the file record if necessary.
+ *
  * @param $node
+ *    Node object this file is be associated with.
  * @param $file
+ *   A single CCK image field item to be updated.
  * @param $field
+ *   The field definition for this image field.
  */
 function imagefield_file_update($node, &$file, $field) {
-  $file = (array)$file; 
+  $file = (array)$file;
   if ($file['flags']['delete'] == TRUE) {
-    if(_imagefield_file_delete($file, $field['field_name'])) {
+    if (_imagefield_file_delete($file, $field['field_name'])) {
       return array();
     }
   }
-  if ($file['fid'] == 'upload') {  
+  if ($file['fid'] == 'upload') {
     return imagefield_file_insert($node, $file, $field);
   }
   else {
     // if fid is not numeric here we should complain.
-    // else we update the file table.  
+    // else we update the file table.
   }
   return $file;
 }
@@ -311,7 +320,7 @@
           $item['flags']['hidden'] = TRUE;
           $item['flags']['delete'] = TRUE;
         }
-        
+
         // Update each file item.
         $items[$delta] = imagefield_file_update($node, $item, $field);
 
@@ -330,7 +339,7 @@
 
     case 'delete':
       foreach ($items as $delta => $item) {
-        _imagefield_file_delete($item, $field['field_name']); 
+        _imagefield_file_delete($item, $field['field_name']);
       }
       break;
 
@@ -347,7 +356,6 @@
   }
 }
 
-
 /**
  * Implementation of hook_widget_info().
  */
@@ -370,47 +378,47 @@
 
     case 'form':
       $form = array();
-      $form['max_resolution'] = array (
-        '#type' => 'textfield', 
-        '#title' => t('Maximum resolution for Images'), 
+      $form['max_resolution'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Maximum resolution for Images'),
         '#default_value' => $widget['max_resolution'] ? $widget['max_resolution'] : 0,
-        '#size' => 15, 
-        '#maxlength' => 10, 
-        '#description' => 
+        '#size' => 15,
+        '#maxlength' => 10,
+        '#description' =>
         t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height.'),
       );
-      $form['max_filesize'] = array (
-        '#type' => 'textfield', 
-        '#title' => t('Maximum filesize for Images'), 
+      $form['max_filesize'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Maximum filesize for Images'),
         '#default_value' => $widget['max_filesize'] ? $widget['max_filesize'] : 0,
-        '#size' => 6, 
+        '#size' => 6,
         '#description' => t('The maximum allowed image file size expressed in kilobytes. Set to 0 for no restriction.')
       );
-      $form['max_number_images'] = array (
-        '#type' => 'textfield', 
-        '#title' => t('Maximum number of images'), 
+      $form['max_number_images'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Maximum number of images'),
         '#default_value' => $widget['max_number_images'] ? $widget['max_number_images'] : 0,
-        '#size' => 4, 
+        '#size' => 4,
         '#description' => t('The maximum number of images allowed. Set to 0 for no restriction. This only applies if multiple values are enabled.')
       );
       $form['image_path'] = array(
-        '#type' => 'textfield', 
-        '#title' => t('Image path'), 
-        '#default_value' => $widget['image_path'] ? $widget['image_path'] : '', 
-        '#description' => t('Optional subdirectory within the "%dir" directory where images will be stored. Do not include trailing slash.', array('%dir' => variable_get('file_directory_path', 'files'))), 
+        '#type' => 'textfield',
+        '#title' => t('Image path'),
+        '#default_value' => $widget['image_path'] ? $widget['image_path'] : '',
+        '#description' => t('Optional subdirectory within the "%dir" directory where images will be stored. Do not include trailing slash.', array('%dir' => variable_get('file_directory_path', 'files'))),
       );
       if (function_exists('token_replace')) {
         $form['image_path']['#description'] .= ' '. t('You can use the following tokens in the image path.');
         $form['image_path']['#suffix'] = theme('token_help', 'user');
       }
-      $form['file_extensions'] = array (
-        '#type' => 'textfield', 
-        '#title' => t('Permitted upload file extensions.'), 
+      $form['file_extensions'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Permitted upload file extensions.'),
         '#default_value' => $widget['file_extensions'] ? $widget['file_extensions'] : 'jpg jpeg png gif',
-        '#size' => 64, 
-        '#maxlength' => 64, 
+        '#size' => 64,
+        '#maxlength' => 64,
         '#description' => t('Extensions a user can upload to this field. Seperate extensions with a space and do not include the leading dot.')
-      );  
+      );
 
       $form['custom_alt'] = array(
         '#type' => 'checkbox',
@@ -450,16 +458,16 @@
 /**
  * Create the image directory relative to the 'files' dir recursively for every
  * directory in the path.
- * 
+ *
  * @param $directory
  *   The directory path under files to check, such as 'photo/path/here'
  * @param $form_element
  *   A form element to throw an error on if the directory is not writable
- */ 
+ */
 function imagefield_check_directory($directory, $form_element = array()) {
-  foreach(explode('/', $directory) as $dir) {
+  foreach (explode('/', $directory) as $dir) {
     $dirs[] = $dir;
-    $path = file_create_path(implode($dirs,'/'));
+    $path = file_create_path(implode($dirs, '/'));
     file_check_directory($path, FILE_CREATE_DIRECTORY, $form_element['#parents'][0]);
   }
   return true;
@@ -473,14 +481,13 @@
       $result = image_scale($file['filepath'], $file['filepath'], $width, $height);
       if ($result) {
         $file['filesize'] = filesize($file['filepath']);
-        drupal_set_message(t('The image %filename was resized to fit within the maximum allowed resolution of %resolution pixels', array('%resolution' => $resolution, '%filename' => $file['filename'])));      
+        drupal_set_message(t('The image %filename was resized to fit within the maximum allowed resolution of %resolution pixels', array('%resolution' => $resolution, '%filename' => $file['filename'])));
       }
     }
   }
   return $file;
 }
 
-
 function imagefield_clear_session() {
   if (is_array($_SESSION['imagefield']) && count($_SESSION['imagefield'])) {
     foreach (array_keys($_SESSION['imagefield']) as $fieldname) {
@@ -531,8 +538,7 @@
       _imagefield_widget_validate($node, $field, $items);
       return;
   }
-}  
-
+}
 
 function _imagefield_widget_prepare_form_values(&$node, $field, &$items) {
   $fieldname = $field['field_name'];
@@ -541,8 +547,8 @@
     imagefield_clear_session();
   }
 
-  // Attach new files 
-  if ($file = file_check_upload($fieldname . '_upload')) {
+  // Attach new files
+  if ($file = file_check_upload($fieldname .'_upload')) {
     $file = (array)$file;
 
     // Validation must happen immediately after the image is uploaded so we
@@ -550,23 +556,23 @@
     $valid_image = _imagefield_widget_upload_validate($node, $field, $items, $file);
     //$valid_image = TRUE;
 
-    if ($valid_image) { 
+    if ($valid_image) {
       $file = _imagefield_scale_image($file, $field['widget']['max_resolution']);
 
       // Allow tokenized paths if available
       if (function_exists('token_replace')) {
         global $user;
-        $widget_image_path = token_replace($field['widget']['image_path'],'user', $user);
+        $widget_image_path = token_replace($field['widget']['image_path'], 'user', $user);
       }
       else {
         $widget_image_path = $field['widget']['image_path'];
       }
       imagefield_check_directory($widget_image_path);
       $filepath = file_create_filename($file['filename'], file_create_path($widget_image_path));
-      
+
       $file['fid'] = 'upload';
       $file['preview'] = $filepath;
-          
+
       // If a single field, mark any other images for deletion and delete files in session
       if (!$field['multiple']) {
         if (is_array($items)) {
@@ -597,14 +603,14 @@
       }
     }
   }
-      
+
   // Load files from preview state. before committing actions.
   if (is_array($_SESSION['imagefield'][$fieldname]) && count($_SESSION['imagefield'][$fieldname])) {
-    foreach($_SESSION['imagefield'][$fieldname] as $delta => $file) {
+    foreach ($_SESSION['imagefield'][$fieldname] as $delta => $file) {
       $items[] = $file;
     }
   }
-}  
+}
 
 function _imagefield_widget_form($node, $field, &$items) {
   drupal_add_js('misc/progress.js');
@@ -612,7 +618,7 @@
 
   $fieldname = $field['field_name'];
   drupal_add_css(drupal_get_path('module', 'imagefield') .'/imagefield.css');
- 
+
   $form = array();
 
   $form[$fieldname] = array(
@@ -625,7 +631,7 @@
     '#prefix' => '<div id="'. form_clean_id($fieldname .'-attach-wrapper') .'">',
     '#suffix' => '</div>',
   );
-      
+
   $form[$fieldname]['new'] = array(
     '#tree' => FALSE,
     '#prefix' => '<div id="'. form_clean_id($fieldname .'-attach-hide') .'">',
@@ -640,7 +646,7 @@
     $form[$fieldname]['new']['#value'] = format_plural($max_images, 'You can only attach one image to this field. Delete the image if you wish to be able to upload a different one.', 'You can only attach @count images to this field. Delete an image if you wish to be able to upload different images.');
   }
   else {
-    // Seperate from tree becase of that silly things won't be 
+    // Seperate from tree becase of that silly things won't be
     // displayed if they are a child of '#type' = form issue
     $form[$fieldname]['new'][$fieldname .'_upload'] = array(
       '#type'  => 'file',
@@ -652,7 +658,7 @@
     $form[$fieldname]['new']['upload'] = array(
       '#type' => 'button',
       '#value' => t('Upload'),
-      '#name' => 'cck_imagefield_'.$fieldname.'_op',
+      '#name' => 'cck_imagefield_'. $fieldname .'_op',
       '#id' => form_clean_id($fieldname .'-attach-button'),
       '#tree' => FALSE,
       '#weight' => 10,
@@ -661,13 +667,12 @@
     $form[$fieldname .'-attach-url'] = array('#type' => 'hidden', '#value' => url('imagefield/js', NULL, NULL, TRUE), '#attributes' => array('class' => 'upload'));
   }
 
-
   // @todo split following if block into its own function.
   // Store the file data object to be carried on.
   if (is_array($items) && count($items)) {
-    foreach($items as $delta => $file) {
+    foreach ($items as $delta => $file) {
       if ($file['filepath'] && !$file['flags']['hidden']) {
-        $form[$fieldname][$delta] = array (
+        $form[$fieldname][$delta] = array(
           '#theme' => 'imagefield_edit_image_row',
         );
 
@@ -676,22 +681,23 @@
           '#title' => t('Delete'),
           '#default_value' => isset($file['flags']['delete']) ? $file['flags']['delete'] : 0,
         );
-       
-        if (function_exists('token_replace')) { 
+
+        if (function_exists('token_replace')) {
           global $user;
           $filename = $file['fid'] == 'upload' ? file_create_filename($file['filename'], file_create_path(token_replace($field['widget']['image_path'], 'user', $user))) : $file['filepath'];
-        } else {
+        }
+        else {
           $filename = $file['fid'] == 'upload' ? file_create_filename($file['filename'], file_create_path($field['widget']['image_path'])) : $file['filepath'];
         }
-        
+
         $form[$fieldname][$delta]['admin_preview'] = array(
           '#type' => 'markup',
           '#value' => theme('imagefield_image', $file, $file['alt'], $file['title'], array('width' => '150'), FALSE),
         );
-        
+
         $form[$fieldname][$delta]['description'] = array(
           '#type' => 'markup',
-          '#value' => '<strong>' . t('Filename: ') . '</strong>' . $file['filename'],
+          '#value' => '<strong>'. t('Filename: ') .'</strong>'. $file['filename'],
         );
 
         $form[$fieldname][$delta]['alt'] = array(
@@ -709,7 +715,7 @@
             '#size' => 10,
           );
         }
-        
+
         $form[$fieldname][$delta]['title'] = array(
           '#type' => 'hidden',
           '#value' => $file['filename'],
@@ -725,7 +731,7 @@
             '#size' => 10,
           );
         }
-        
+
         // Special handling for single value fields
         if (!$field['multiple']) {
           $form[$fieldname][$delta]['replace'] = array(
@@ -753,8 +759,6 @@
     }
   }
 
-
-
   // Some useful info for our js callback.
   $form['vid'] = array(
     '#type' => 'hidden',
@@ -771,7 +775,7 @@
     '#value' => $node->type,
     '#tree' => FALSE,
   );
-   
+
   return $form;
 }
 
@@ -779,44 +783,44 @@
  * Validate the widget.
  */
 function _imagefield_widget_validate($node, $field, $items) {
-  
+
   if ($field['required']) {
     // Sum all the items marked for deletion, so we can make sure the end user
     // isn't deleting all of the images.
     $deleted = 0;
-    foreach($items as $item) {
+    foreach ($items as $item) {
       if ($item['flags']['delete']) {
         $deleted++;
       }
     }
 
-    if (!count($items)) { 
-      form_set_error($field['field_name'], $field['widget']['label'] .' is required. Please upload an image.');
+    if (!count($items)) {
+      form_set_error($field['field_name'], t('%field is required. Please upload an image.', array('%field' => $field['widget']['label'])));
     }
     else if (count($items) == $deleted ) {
-      form_set_error($field['field_name'], $field['widget']['label'] .' is required. Please uncheck at least one delete checkbox or upload another image.');
+      form_set_error($field['field_name'],  t('%field is required. Please uncheck at least one delete checkbox or upload another image.'), array('%field' => $field['widget']['label']));
     }
   }
-}  
+}
 
 function _imagefield_widget_upload_validate($node, $field, $items, $file) {
   // initialize our validation state, innocent until proven guilty.
   $valid = TRUE;
 
-  // do we even need to test file extensions?
+  // Do we even need to test file extensions?
   if (!empty($field['widget']['file_extensions'])) {
-    // pop out the extensions and turn file_extensions into an array.
+    // Pop out the extensions and turn file_extensions into an array.
     $ext = strtolower(array_pop(explode('.', $file['filename'])));
     $allowed_extensions = array_unique(explode(' ', strtolower(trim($field['widget']['file_extensions']))));
-    // is it the file extension in the allowed_extensions array?
+    // Is it the file extension in the allowed_extensions array?
     if (!in_array($ext, $allowed_extensions)) {
-      // sorry no..
+      // Sorry no..
       form_set_error($field['field_name'], t('Files with the extension %ext are not allowed. Please upload a file with an extension from the following list: %allowed_extensions', array('%ext' => $ext, '%allowed_extensions' => $field['widget']['file_extensions'])));
       $valid = FALSE;
     }
   }
 
-  // If max filesize is set
+  // If max filesize is set.
   if (!empty($field['widget']['max_filesize'])) {
     if ($file['filesize'] > ($field['widget']['max_filesize'] * 1024)) {
       form_set_error($field['field_name'], t('The file you uploaded has a filesize greater than the maximum allowed filesize of %sizekb.', array('%size' => $field['widget']['max_filesize'])));
@@ -824,7 +828,7 @@
     }
   }
 
-  // is the mime type a match for image.
+  // Is the mime type a match for image.
   if (strpos($file['filemime'], 'image/') !== 0) {
     // sorry no it isn't. do not pass go, do not collect $200.
     form_set_error($field['field_name'], t('Mime Type mismatch. Only image files may be upload. You uploaded a file with mime type: %mime', array('%mime' => $file['filemime'])));
@@ -859,7 +863,6 @@
 
 /**
  * Implementation of hook_field_formatter().
- *
  */
 function imagefield_field_formatter($field, $item, $formatter, $node = NULL) {
   if (empty($item['fid']) && $field['use_default_image']) {
@@ -874,10 +877,9 @@
   }
 }
 
-
 function _imagefield_file_load($fid = NULL) {
   // Don't bother if we weren't passed and fid.
-  if (!empty($fid) && is_numeric($fid)) { 
+  if (!empty($fid) && is_numeric($fid)) {
     $result = db_query('SELECT * FROM {files} WHERE fid = %d', $fid);
     $file = db_fetch_array($result);
     if ($file) {
@@ -892,8 +894,6 @@
   return theme('imagefield_image', $file, $alt, $title, $attributes , $getsize);
 }
 
-
-
 function theme_imagefield_edit_image_row($element) {
   $output = '<div class="imagefield-edit-preview">'. drupal_render($element['admin_preview']) .'</div>';
   $output .= '<div class="imagefield-edit-image-detail">';
@@ -903,17 +903,16 @@
   $output .= drupal_render($element['alt']);
   $output .= drupal_render($element['title']);
   $output .= '</div>';
-  //$output .= '<div class="imagefield-edit-image-fid">'. $element['fid']['#value'] .'</div>';
   $output = '<div class="imagefield-edit-image-row clear-block">'. $output .'</div>';
   if (isset($element['replace'])) {
     $output .= '<div class="imagefield-edit-image-replace">'. drupal_render($element['replace']) .'</div>';
   }
-  return $output;  
+  return $output;
 }
 
 function theme_imagefield_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
   $file = (array)$file;
-  if (!is_file($file['filepath'])) {    
+  if (!is_file($file['filepath'])) {
     return;
   }
   if (!$getsize || (list($width, $height, $type, $image_attributes) = @getimagesize($file['filepath']))) {
@@ -928,21 +927,22 @@
 }
 
 /**
- * formats an array of images.
+ * Formats an array of images.
+ *
  * @param images
  *    array of individually themed images
- * @return 
+ * @return
  *    html string
  */
 function theme_imagefield_multiple($images) {
   return implode("\n", $images);
 }
 
-/** 
- * implementation of hook_filedownload
- * replicated from upload.module.
+/**
+ * Implementation of hook_file_download().
+ * Replicated from upload.module.
  *
- * conditionally included since we're just replicating the 
+ * Conditionally included since we're just replicating the
  * work of upload.module for now.
  */
 
@@ -991,18 +991,16 @@
 function imagefield_js() {
   // Parse fieldname from submit button.
   $matches = array();
-  foreach(array_keys($_POST) as $key) {
+  foreach (array_keys($_POST) as $key) {
     if (preg_match('/cck_imagefield_(.*)_op/', $key, $matches)) {
       break;
     }
   }
-  $fieldname = $matches[1]; 
-  
-    
+  $fieldname = $matches[1];
+
   $node = (object)$_POST;
   // Load field data.
   $field = content_fields($fieldname, $node->type);
-  
 
   // Load fid's stored by content.module
   $items = array();
@@ -1015,9 +1013,9 @@
   // Handle uploads and validation.
   _imagefield_widget_prepare_form_values($node, $field, $items);
   _imagefield_widget_validate($node, $field, $items);
-  
-  if(is_array($node->{$fieldname}) && count($node->{$fieldname}) > 0) {
-    foreach($node->{$fieldname} as $key => $image) {
+
+  if (is_array($node->{$fieldname}) && count($node->{$fieldname}) > 0) {
+    foreach ($node->{$fieldname} as $key => $image) {
       // Set the alt and title from POST
       $items[$key]['alt'] = $image['alt'];
       $items[$key]['title'] = $image['title'];
