diff --git a/library/markdown/markdowneditor.js b/library/markdown/markdowneditor.js
index 80a9e7a..98996db 100644
--- a/library/markdown/markdowneditor.js
+++ b/library/markdown/markdowneditor.js
@@ -1623,6 +1623,52 @@ markdownEditor.image = function () {
 };
 
 /**
+ * Displays a dialog where the user can add an inline image using image styles (D7).
+ * The reference is added to the reference section of the BUE. The IMCE dialog is integrated
+ * if IMCE is enabled.
+ */
+markdownEditor.image_with_style = function (filepath, presets) {
+  var t = markdownEditor.t;
+  var tag = Cactus.DOM.tag;
+  var createForm = markdownEditor.dialog.createForm;
+
+  // Default values for form fields.
+  var hrefValue = "";
+  var referenceValue = "";
+  var titleValue = "";
+  var textValue = BUE.active.getSelection();
+  var inlineValue = null;
+
+  // Remove empty presets from list.
+  if ("" in presets) {
+    presets[""] = t("Original");
+  }
+
+  // Creating the form for the dialog.
+  var form = createForm(
+    { label : t("Alt"), mandatory : true, attributes : { name : "alt", value : textValue } },
+    { label : t("Title"), attributes : { name : "title", value : titleValue } },
+    { label : t("Preset"), mandatory : true, tagName : "select", options : presets, attributes : { name : "preset" } },
+    { label : t("Reference"), attributes : { name : "reference", value : referenceValue } },
+    { label : t("URL"), mandatory : true, attributes : { name : "href", value : hrefValue } },
+    { label : t("Inline"), attributes : { name : "inline", type : "checkbox", value: inlineValue } }
+  );
+
+  // Create an onsubmit handler and various buttons.
+  var submitFunction = markdownEditor.image._process_styled.bind(null, form, filepath, "Images");
+  var mDialog = markdownEditor.dialog;
+  mDialog.setOnsubmit(form, submitFunction);
+  mDialog.addIMCELink(form.elements.href.parentNode, form.elements.href);
+  mDialog.addSubmitButton(form, submitFunction);
+  mDialog.addCancelButton(form);
+
+  // Open the dialog and display the form.
+  mDialog.open(t("Insert image"), "image");
+  mDialog.getContent().appendChild(form);
+  mDialog.focusFirst();
+};
+
+/**
  * Handles submissions for adding images.
  *
  * @param form
@@ -1670,6 +1716,63 @@ markdownEditor.image._process = function (form) {
 };
 
 
+/**
+ * Handles submissions for adding styled images.
+ *
+ * @param form
+ *   The form element of the dialog.
+ */
+markdownEditor.image._process_styled = function (form, filepath) {
+  var Reference = markdownEditor.Reference;
+  var t = markdownEditor.t;
+
+  var referenceType = "Images";
+  var alt = form.elements.alt.value;
+  var title = form.elements.title.value;
+  var reference = form.elements.reference.value || alt;
+  var href = form.elements.href.value;
+  var inline = form.elements.inline.checked || false;
+  var preset = form.elements.preset.value;
+
+  // Validate input.
+  markdownEditor.dialog.clearErrors();
+  var valid = true;
+  if (!alt) {
+    markdownEditor.dialog.addError(t("Alt is a required field."));
+    valid = false;
+  }
+  if (!href) {
+    markdownEditor.dialog.addError(t("URL is a required field."));
+    valid = false;
+  }
+  if (!valid) {
+    return;
+  }
+
+  // Alter URL using selected style.
+  if (preset) {
+    if (href.indexOf(filepath) == 0) {
+      href = filepath +'/styles/'+ preset + '/public' + href.substr(filepath.length);
+    }
+    preset = '';
+  }
+
+  if (inline) {
+    // Insert inline link after caret position
+    var replaceString = "![" + alt + "](" + href + ( title ? ' "' + title + '"' : '' ) + ")";
+    markdownEditor.selection.replaceAll(replaceString);
+    BUE.dialog.close();
+  }
+  else {
+    // The text added at the caret position.
+    var textString = alt ? "![" + alt + "][" + reference + "]" : "![" + reference + "]";
+    // The reference to add to the reference section.
+    var ref = new Reference(referenceType, reference, href + (title ? ' "' + title + '"' : ""));
+    markdownEditor.references._callback(textString, ref);
+  }
+};
+
+
 /*******************************************************************************
  * FOOTNOTE
  ******************************************************************************/
diff --git a/markdowneditor.buttons.inc b/markdowneditor.buttons.inc
index cb8ecf1..752528c 100644
--- a/markdowneditor.buttons.inc
+++ b/markdowneditor.buttons.inc
@@ -172,11 +172,31 @@ $mde_buttons[$i++] = array(
 
 $mde_buttons[$i++] = array(
   $eid,
+  t("Insert a styled image"),
+  'php:
+    if (!function_exists("image_styles")) return "js: markdownEditor.image();";
+    $filepath = url(file_stream_wrapper_get_instance_by_scheme("public")->getDirectoryPath());
+    $presets = array("" => "");
+    foreach (image_styles() as $name => $style) {
+      $presets[$name] = $name;
+    }
+    $presets = drupal_json_encode($presets);
+    return "js:
+      markdownEditor.image_with_style(\'$filepath\', $presets);
+    ";
+  ',
+  "md-add-picture.gif",
+  "M",
+  5,
+);
+
+$mde_buttons[$i++] = array(
+  $eid,
   t("Insert a line break"),
   "js: markdownEditor.lineBreak();",
   "md-add-line.gif",
   "R",
-  5,
+  6,
 );
 
 $mde_buttons[$i++] = array(
@@ -185,7 +205,7 @@ $mde_buttons[$i++] = array(
   "js: markdownEditor.horizontalRuler();",
   "md-add-hr.gif",
   "",
-  6,
+  7,
 );
 
 $mde_buttons[$i++] = array(
@@ -194,7 +214,7 @@ $mde_buttons[$i++] = array(
   "<!--break-->",
   "teaserbr.png",
   "T",
-  7,
+  8,
 );
 
 if (module_exists('ajax_markup')) {
@@ -204,7 +224,7 @@ if (module_exists('ajax_markup')) {
     "js: E.prvAjax();",
     "preview.png",
     "P",
-    8,
+    9,
   );
   $ajax_markup_exist = 'We have ajax markup!';
 }
@@ -215,7 +235,7 @@ $mde_buttons[$i++] = array(
   "js: E.help('fadeIn');",
   "md-help.gif",
   "",
-  9,
+  10,
 );
 
 // EoF
