Index: imagefield_extended.module
===================================================================
--- imagefield_extended.module	(revision 250)
+++ imagefield_extended.module	(revision 269)
@@ -48,6 +48,13 @@
       'template' => 'imagefield-extended-image',
     ),
   );
+  $themes['imagefield_extended_insert_formatter_ife'] = array(
+    'arguments' => array(
+      'image' => NULL,
+      'style' => NULL,
+      'widget' => NULL,
+    ),
+  );
   // Add imagecache support.
   if (module_exists('imagecache')) {
     $rules = array();
@@ -64,6 +71,15 @@
         'arguments' => array('element' => NULL),
         'function' => 'theme_imagefield_extended_formatter_ife',
       );
+      
+      $themes['imagefield_extended_insert_formatter_'. str_replace('-', '_', $preset) .'_ife'] = array(
+        'arguments' => array(
+          'image' => NULL,
+          'style' => NULL,
+          'widget' => NULL,
+        ),
+        'function' => 'theme_imagefield_extended_insert_formatter_ife',
+      );
     }
   }
   return $themes;
@@ -389,7 +405,6 @@
     'field_name' => check_plain($field_name),
     'image_class' => 'imagefield imagefield-'. $field_name,
   );
-
   $item = (array) $item;
   if (!is_file($item['filepath'])) {
     $variables['image'] = '<!-- File not found: '. check_plain($item['filepath']) .' -->';
@@ -478,3 +493,63 @@
   return array('imagefield_extended');
 }
 
+/**
+ * Implementation of hook_insert_styles().
+ */
+function imagefield_extended_insert_styles() {
+  $formatters = imagefield_extended_field_formatter_info();
+  $styles = array();
+  foreach ($formatters as $formatter_id => $formatter_info) {
+    $styles[$formatter_id] = $formatter_info;
+  }
+  return $styles;
+}
+
+/**
+ * Implementation of hook_insert_content().
+ */
+function imagefield_extended_insert_content($item, $style, $widget) {
+  return theme('imagefield_extended_insert_formatter_'. str_replace('-', '_', $style['name']), $item, $style, $widget);
+}
+
+function theme_imagefield_extended_insert_formatter_ife($item, $style, $widget) {
+  $content = '';
+
+  if (!is_file($item['filepath'])) {
+    return '<!-- File not found: '. $item['filepath'] .' -->';
+  }
+
+  $item['data']['alt'] = isset($item['data']['alt']) ? $item['data']['alt'] : '';
+  $item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL;
+
+  $widget = $widget;
+  $data = array();
+  $extended_fields = _imagefield_extended_fields();
+  foreach ($extended_fields['textfields'] as $key => $title) {
+    if (!empty($widget['custom_'. $key])) {
+      $text = imagefield_extended_check_text($item['data'][$key]);
+      if (!empty($text)) {
+        $data[$key] = array(
+          '#title' => check_plain($title),
+          '#type' => 'item',
+          '#value' => $text,
+        );
+      }
+    }
+  }
+  foreach ($extended_fields['checkboxes'] as $key => $title) {
+    if (!empty($widget['workflow_'. $key])) {
+      $data[$key] = array(
+        '#type' => 'value',
+        '#title' => check_plain($title),
+        '#value' => !empty($widget['workflow_'. $key]),
+      );
+    }
+  }
+  $item['field_name'] = $style['name'];
+  $item['formatter'] = $style['name'];
+
+  $content = theme('imagefield_extended_image', $item, $data);
+
+  return $content;
+}
