diff --git a/caption-filter.js b/caption-filter.js
new file mode 100644
index 0000000..2eb17ae
--- /dev/null
+++ b/caption-filter.js
@@ -0,0 +1,15 @@
+/**
+ * @file
+ * JavaScript integrations between the Caption Filter module and particular
+ * WYSIWYG editors. This file also implements Insert module hooks to respond
+ * to the insertion of content into a WYSIWYG or textarea.
+ */
+(function ($) {
+
+$(document).bind('insertIntoActiveEditor', function(event, options) {
+  if (options['fields']['title'] && Drupal.settings.captionFilter.widgets[options['widgetType']]) {
+    options['content'] = '[caption caption="' + options['fields']['title'] + '"]' + options['content'] + '[/caption]';
+  }
+});
+
+})(jQuery);
diff --git a/caption_filter.install b/caption_filter.install
new file mode 100644
index 0000000..e27d256
--- /dev/null
+++ b/caption_filter.install
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @file
+ * Update and install functions for FileField Sources.
+ */
+
+/**
+ * Implementation of hook_install().
+ */
+function caption_filter_install() {
+  // Caption Filter needs to load after Insert module.
+  db_query("UPDATE {system} SET weight = 20 WHERE type = 'module' AND name = 'caption_filter'");
+}
+
+/**
+ * Set the Caption Filter module weight.
+ */
+function caption_filter_update_6100() {
+  $ret = array();
+
+  // Caption Filter needs to load after Insert module.
+  $ret[] = update_sql("UPDATE {system} SET weight = 20 WHERE type = 'module' AND name = 'caption_filter'");
+
+  return $ret;
+}
diff --git a/caption_filter.module b/caption_filter.module
index 5f16b57..5e3a67c 100644
--- a/caption_filter.module
+++ b/caption_filter.module
@@ -12,6 +12,7 @@
  */
 function caption_filter_init() {
   drupal_add_css(drupal_get_path('module', 'caption_filter') .'/caption-filter.css');
+  drupal_add_js(drupal_get_path('module', 'caption_filter') .'/caption-filter.js');
 }
 
 /**
@@ -78,6 +79,7 @@ function _caption_filter_replace($matches) {
 
   $width = _caption_filter_get_width($item);
   $align = isset($caption_attributes['align']) ? $caption_attributes['align'] : 'center';
+  $caption = isset($caption_attributes['caption']) ? $caption_attributes['caption'] : '';
 
   // Remove "align" from the start of the alignment if needed. WordPress
   // commonly uses align="alignright" for example.
@@ -85,7 +87,7 @@ function _caption_filter_replace($matches) {
     $align = substr($align, 5);
   }
 
-  return '<div class="caption caption-'. $align .'"><div class="caption-inner" style="width: '. $width .';">'. $item .'</div></div>';
+  return '<div class="caption caption-'. $align .'"><div class="caption-inner" style="width: '. $width .';">'. $item . $caption .'</div></div>';
 }
 
 /**
@@ -170,3 +172,111 @@ function _caption_filter_tag_attributes($text) {
   }
   return $atts;
 }
+
+/**
+ * Implements hook_element_info().
+ */
+function caption_filter_elements() {
+  // We only enhance widgets if the Insert module is available.
+  if (!function_exists('insert_widgets')) {
+    return;
+  }
+
+  $extra = array('#after_build' => array('caption_filter_element_process'));
+
+  $elements = array();
+  foreach (insert_widgets() as $widget_type => $widget) {
+    if (isset($widget['fields']['title'])) {
+      $element_type = isset($widget['element_type']) ? $widget['element_type'] : $widget_type;
+      $elements[$element_type] = $extra;
+    }
+  }
+
+  return $elements;
+}
+
+/**
+ * Form API #process function for elements.
+ */
+function caption_filter_element_process($element) {
+  static $js_added;
+dsm($element);
+
+  $field = content_fields($element['#field_name'], $element['#type_name']);
+
+  $widget_settings = $field['widget'];
+  $widget_type = $field['widget']['type'];
+
+  if (isset($element['data']['title'])) {
+    $element['data']['title']['#title'] = t('Caption');
+    $element['data']['title']['#description'] = NULL;
+
+    // Add settings for this widget only once.
+    if (!isset($js_added[$widget_type])) {
+      $js_added[$widget_type] = TRUE;
+      $caption_settings = array(
+        'captionFromTitle' => $widget_settings['caption_from_title'],
+      );
+      drupal_add_js(array('captionFilter' => array('widgets' => array($widget_type => $caption_settings))), 'setting');
+    }
+  }
+
+  return $element;
+}
+
+/**
+ * Implementation of hook_widget_settings_alter().
+ */
+function caption_filter_widget_settings_alter(&$settings, $op, $widget) {
+  // Only support modules that implement hook_insert_widgets().
+  $widget_type = isset($widget['widget_type']) ? $widget['widget_type'] : $widget['type'];
+  if (!function_exists('insert_widgets') || !in_array($widget_type, array_keys(insert_widgets()))) {
+    return;
+  }
+
+  // Add our new options to the list of settings to be saved.
+  if ($op == 'save') {
+    $settings = array_merge($settings, caption_filter_widget_settings());
+  }
+
+  // Add the additional settings to the form.
+  if ($op == 'form' && isset($settings['title_settings']['custom_title'])) {
+    $settings['insert'] = array_merge($settings['insert'], caption_filter_widget_form($widget));
+  }
+}
+
+/**
+ * A list of settings needed by Caption Filter module on widgets.
+ */
+function caption_filter_widget_settings() {
+  return array(
+    'caption_from_title',
+  );
+}
+
+/**
+ * Configuration form for editing insert settings for a field instance.
+ */
+function caption_filter_widget_form($widget) {
+  $settings = $widget['settings'];
+
+  $form['caption_from_title'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use the <em>Title</em> field as a caption'),
+    '#default_value' => isset($settings['caption_from_title']) ? $settings['caption_from_title'] : 1,
+    '#element_validate' => array('caption_filter_field_widget_caption_validate'),
+    '#description' => t('This feature requires that the <em>Title</em> field be enabled above, and that the "Caption filter" be enabled in the <a href="!formats">input formats configuration</a>.', array('!formats' => url('admin/settings/filters'))),
+    '#weight' => -9,
+  );
+
+  return $form;
+}
+
+/**
+ * An #element_validate function for the "caption_from_title" field.
+ */
+function caption_filter_field_widget_caption_validate($element, &$form_state) {
+  if ($element['#value'] && empty($form_state['values']['custom_title'])) {
+    form_error($element, t('The <em>Title</em> field must be enabled to use it as a caption.'));
+  }
+}
