*** img_assist.module	Tue Nov  7 10:44:41 2006
--- img_assist.module.patched	Tue Nov  7 11:11:54 2006
***************
*** 87,93 ****
   * Implementation of hook_perm().
   */
  function img_assist_perm() {
!   return array('access img_assist', 'access all images', 'access advanced options');
  }
  
  /**
--- 87,93 ----
   * Implementation of hook_perm().
   */
  function img_assist_perm() {
!   return array('access img_assist', 'access all images', 'access advanced options', 'use original size');
  }
  
  /**
***************
*** 725,730 ****
--- 725,731 ----
      $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));
+     $image_info = image_get_info(file_create_path($node->images['_original']));
  
      // Select (or generate) a preview image
      $img_assist_create_derivatives = variable_get('img_assist_create_derivatives', array());
***************
*** 769,774 ****
--- 770,782 ----
        }
      }
  
+     // Add a choice for 'original' if it's within the maximum size.
+     if ($img_assist_create_derivatives['custom_advanced'] && user_access('use original size')) {
+       if ($image_info['width'] <= $max_size[0] && $image_info['height'] <= $max_size[1]) {
+         $derivatives[$image_info['width']  .'x' . $image_info['height']] = t('original');
+       }
+     }
+ 
      // Add a choice for 'other' if the user has the proper permission to create custom sizes
      if ($img_assist_create_derivatives['custom_advanced'] && user_access('access advanced options')) {
        $derivatives['other'] = t('other');
***************
*** 823,829 ****
      // Size
      $form[] = array('#value'=>"</td></tr><tr><td width=\"90%\">\n");
      $form[] = array('#value'=>"<div class=\"form-item\" id=\"size\">\n");
!     $form[] = array('#value'=>"<label for=\"edit-size\">Size:</label>\n");
      $form['size_label'] = array(
        '#type' => 'select',
        '#default_value' => variable_get('img_assist_default_label', '100x100'),
--- 831,837 ----
      // Size
      $form[] = array('#value'=>"</td></tr><tr><td width=\"90%\">\n");
      $form[] = array('#value'=>"<div class=\"form-item\" id=\"size\">\n");
!     $form[] = array('#value'=>"<label for=\"edit-size\">Size: (orig " . $image_info['width'] . 'x' . $image_info['height'] . ", max " . variable_get('img_assist_max_size', '640x640') . ")</label>\n");
      $form['size_label'] = array(
        '#type' => 'select',
        '#default_value' => variable_get('img_assist_default_label', '100x100'),
***************
*** 854,860 ****
        '#type' => 'select',
        '#title' => t('Alignment'),
        '#default_value' => variable_get('img_assist_default_alignment', 'left'),
!       '#options' => array('left'=>'left', 'right'=>'right'),
        '#prefix' => '<span id="alignment">',
        '#suffix' => '</span>'
      );
--- 862,868 ----
        '#type' => 'select',
        '#title' => t('Alignment'),
        '#default_value' => variable_get('img_assist_default_alignment', 'left'),
!       '#options' => array('left'=>'left', 'right'=>'right', 'none'=>'none', 'center'=>'center'),
        '#prefix' => '<span id="alignment">',
        '#suffix' => '</span>'
      );
***************
*** 1262,1268 ****
    $node->title = strip_tags($caption); // change the node title because img_assist_display() uses the node title for alt and title
    $img_tag = img_assist_display($node, $size);
  
!   $output  = "<span class=\"inline {$attributes['align']}\">";
    $link = explode(',', $attributes['link']);
  
    if ($link[0] == 'node') {
--- 1270,1280 ----
    $node->title = strip_tags($caption); // change the node title because img_assist_display() uses the node title for alt and title
    $img_tag = img_assist_display($node, $size);
  
!   if ( $attributes['align'] == "center" ) {
!     $output = "<span class=\"inline {$attributes['align']}\" style=\"width: {$attributes['width']}px;\">";
!   } else {
!     $output  = "<span class=\"inline {$attributes['align']}\">";
!   }
    $link = explode(',', $attributes['link']);
  
    if ($link[0] == 'node') {
***************
*** 1648,1651 ****
  	return "<div class=\"%image-class\">\n  <a href=\"%node-link\"><img src=\"%src\" width=\"%width\" height=\"%height\" alt=\"%alt\" /></a>\n  <div class=\"caption\">%caption</div>\n</div>";
  }
  
! ?>
\ No newline at end of file
--- 1660,1663 ----
  	return "<div class=\"%image-class\">\n  <a href=\"%node-link\"><img src=\"%src\" width=\"%width\" height=\"%height\" alt=\"%alt\" /></a>\n  <div class=\"caption\">%caption</div>\n</div>";
  }
  
! ?>
