--- inline.module 19 Aug 2006 16:09:54 -0000  1.18
+++ inline.module 11 Sep 2006 10:15:17 -0000
@@ -54,24 +54,17 @@
 }
 
 function inline_filter($op, $delta = 0, $format = -1, $text = '') {
-  // The "list" operation provides the module an opportunity to declare both how
-  // many filters it defines and a human-readable name for each filter. Note that
-  // the returned name should be passed through t() for translation.
-  if ($op == 'list') {
-    return array(
-      0 => t('Inline file filter'));
-  }
-
-  // All operations besides "list" provide a $delta argument so we know which
-  // filter they refer to. We'll switch on that argument now so that we can
-  // discuss each filter in turn.
   switch ($op) {
+    case 'list':
+      return array(0 => t('Inline file filter'));
     case 'description':
-       return t('Substitutes [inline:xx] tags with the xxth file uploaded with the node.');
+      return t('Substitutes [inline:xx] tags with the xxth file uploaded with the node.');
     case 'prepare':
-       return $text;
+      return $text;
     case 'process':
-       return $text;
+      return $text;
+    default:
+      return $text;
   }
 }
 
@@ -150,31 +143,31 @@
  */
 function inline_prepare_file_object($file) {
   $file = (object)$file;
-  $tmp = file_directory_temp();
-  if (strpos($file->filepath, $tmp) === 0) {
-    $file->real_path = $file->filepath;
-    $file->filepath = $file->filename;
-    $file->preview = TRUE;
-  }
+
+  $file->preview = (strpos($file->filepath, file_directory_temp()) === 0);
+
   return $file;
 }
 
 
 function theme_inline_as_link($file) {
   // prepare link text with title or filename
-  $linktext = ($file->title ? $file->title : $file->name);
-
-  return l($linktext, file_create_url($file->filepath), array('title' => t('Download: %name (%size)', array('%name' => $file->filename, '%size' => format_size($file->filesize)))));
+  return l($file->title, file_create_url($file->filepath), array('title' => t('Download: %name (%size)', array('%name' => $file->filename, '%size' => format_size($file->filesize)))));
 }
 
 function theme_inline_img($file) {
+  if($file->preview) {
+    $filepath = '/' . drupal_get_path('module', 'inline') . '/image.php?filename=' . urlencode($file->filepath);
+  }
+  else {
+    $filepath = file_create_url($file->filepath);
+  }
+  
   if (variable_get('inline_link_img', '1') == '1') {
-    $html .= '<a href="'. file_create_url($file->filepath) . '" title="'.t("View").': '. $file->name .'">';
+    $html .= '<a href="'. $filepath . '" title="'.t("View").': '. $file->description .'">';
   }
 
-  $title = ( $file->title ? $file->title : $file->name );
-
-  $html .= '<img style="width: '.$file->width.'px; height:'.$file->height.'px;" src="'. file_create_url($file->filepath). '" class="inline" alt="'. $title .'" title="'. $title.'" />';
+  $html .= '<img src="'. $filepath. '" class="inline" alt="'. $file->title .'" title="'. $file->description.'" />';
 
   if (variable_get('inline_link_img', '1') == '1') {
     $html .= '</a>';
@@ -247,6 +240,9 @@
       if (!empty( $title )) {
         $file->title = $title;
       }
+      else {
+        $file->title = $file->description;
+      }
       $replace = "";
       if ($file->fid != NULL) {
         //decide if we should show a link or an img tag
@@ -279,18 +275,13 @@
   if (in_array($mime, $inlined)) {
     // read settings
     list($maxwidth, $maxheight) = explode(',',variable_get('inline_img_dim', '150,150'));
-
-    if ($file->preview) {
-      list($width, $height) = getimagesize($file->real_path);
-    }
-    else {
-      list($width, $height) = getimagesize($file->filepath);
-    }
+    list($width, $height) = getimagesize($file->filepath);
 
     if (($width && $height) && ($width <= $maxwidth && $height <= $maxheight)) {
       return TRUE;
     }
   }
+  
   return FALSE;
 }
 ?>
