Index: filefield-insert-image.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield_insert/filefield-insert-image.tpl.php,v
retrieving revision 1.2
diff -u -r1.2 filefield-insert-image.tpl.php
--- filefield-insert-image.tpl.php	10 May 2009 19:50:58 -0000	1.2
+++ filefield-insert-image.tpl.php	16 Jun 2009 05:17:53 -0000
@@ -17,8 +17,16 @@
  * their real values by JavaScript.
  */
 ?>
+<?php
+  if ($field['widget']['filefield_insert_presets_linkoriginal'])
+    print $a_starttag;
+?>
 <?php if ($field['widget']['module'] == 'imagefield'): // Use the ALT and Title fields if available. ?>
   <img src="<?php print $url ?>" alt="<?php print $alt ?>" title="<?php print $title ?>" width="<?php print $width ?>" height="<?php print $height ?>" />
 <?php else: // For FileField, use the description for both fields. ?>
   <img src="<?php print $url ?>" alt="<?php print $description ?>" title="<?php print $description ?>" width="<?php print $width ?>" height="<?php print $height ?>" />
-<?php endif; ?>
\ No newline at end of file
+<?php endif; ?>
+<?php 
+  if ($field['widget']['filefield_insert_presets_linkoriginal'])
+    print $a_endtag;
+?>
\ No newline at end of file
Index: filefield_insert.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield_insert/filefield_insert.js,v
retrieving revision 1.5
diff -u -r1.5 filefield_insert.js
--- filefield_insert.js	15 Jun 2009 16:18:36 -0000	1.5
+++ filefield_insert.js	16 Jun 2009 05:18:52 -0000
@@ -55,9 +55,13 @@
     var preset = $preset.size() ? $preset.val() : '';
     var fileDir = Drupal.settings.fileFieldInsert.fileDirectoryPath;
     var content = '';
+    var a_starttag = '';
+    var a_endtag = '';
 
     // Update the URL if using a preset.
     if (preset) {
+      a_starttag = "<a href='" + url + "' rel='lightbox'>";
+      a_endtag = "</a>";
       var pieces = preset.split('|');
       url = url.replace(fileDir + '/', fileDir + '/imagecache/' + pieces[0] + '/');
       // If the ImageCache preset specified both height and width.
@@ -108,7 +112,7 @@
     url = encodeURI(url).replace(/([#$*(),?])/g, function(match) { return escape(match) });
 
     // Update replacements.
-    content = $.trim(content).replace(/__url__/g, url).replace(/__extension__/g, extension).replace(/__width__/g, width).replace(/__height__/g, height).replace(/__description__/g, description);
+    content = $.trim(content).replace(/__url__/g, url).replace(/__extension__/g, extension).replace(/__width__/g, width).replace(/__height__/g, height).replace(/__description__/g, description).replace(/__a_starttag__/g,a_starttag).replace(/__a_endtag__/g,a_endtag);
     if (Drupal.settings.fileFieldInsert.templates.image) {
       content = content.replace(/__alt__/g, alt).replace(/__title__/g, title);
     }
Index: filefield_insert.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield_insert/filefield_insert.module,v
retrieving revision 1.4
diff -u -r1.4 filefield_insert.module
--- filefield_insert.module	10 May 2009 19:50:58 -0000	1.4
+++ filefield_insert.module	16 Jun 2009 05:19:12 -0000
@@ -205,6 +205,12 @@
         '#default_value' => $options['default'],
         '#description' => t('Select which ImageCache presets should be available when sending images to text areas. If no presets are selected, the option to use a preset is not displayed.'),
       );
+      $form['filefield_insert']['filefield_insert_presets_linkoriginal'] = array(
+	    '#type' => 'checkbox',
+	    '#title' => t('Link to original'),
+	    '#default_value' => $field['widget']['filefield_insert_presets_linkoriginal'],
+	    '#description' => t('Adds a link to the original image for any image size that is not the original size.'),
+  	  );
     }
     else {
       $form['filefield_insert']['#description'] .= ' ' . t('Note that only file fields that use the "Image" widget type support ImageCache configuration options.');
@@ -231,6 +237,7 @@
   $settings = array(
     'filefield_insert' => FALSE,
     'filefield_insert_presets' => array(),
+    'filefield_insert_presets_linkoriginal' => FALSE,
     'filefield_insert_width' => '',
   );
 
@@ -244,7 +251,7 @@
 
   $settings['filefield_insert'] = (bool) $form_state['values']['filefield_insert'];
   $settings['filefield_insert_width'] = empty($form_state['values']['filefield_insert_width']) ? 0 : (int)$form_state['values']['filefield_insert_width'];
-
+  $settings['filefield_insert_presets_linkoriginal'] = (bool) $form_state['values']['filefield_insert_presets_linkoriginal'];
   filefield_insert_set_settings($field, $settings);
 }
 
@@ -262,6 +269,7 @@
   return array(
     'filefield_insert' => empty($settings['filefield_insert']) ? FALSE : $settings['filefield_insert'],
     'filefield_insert_presets' => empty($settings['filefield_insert_presets']) ? array() : $settings['filefield_insert_presets'],
+    'filefield_insert_presets_linkoriginal' => empty($settings['filefield_insert_presets_linkoriginal']) ? FALSE : $settings['filefield_insert_presets_linkoriginal'],
     'filefield_insert_width' => empty($settings['filefield_insert_width']) ? '' : $settings['filefield_insert_width'],
   );
 }
@@ -293,6 +301,8 @@
   $vars['extension'] = '__extension__';
   $vars['height'] = '__height__';
   $vars['width'] = '__width__';
+  $vars['a_starttag'] = '__a_starttag__';
+  $vars['a_endtag'] = '__a_endtag__';
 }
 
 /**

