diff --git a/modules/contrib/image_caption/image_caption.js b/modules/contrib/image_caption/image_caption.js
index 6b9433e..e79d239 100644
--- a/modules/contrib/image_caption/image_caption.js
+++ b/modules/contrib/image_caption/image_caption.js
@@ -5,6 +5,8 @@ Drupal.behaviors.image_caption = {
     $("img.caption:not(.caption-processed)").each(function(i) {
       var imgwidth = $(this).width() ? $(this).width() : false;
       var imgheight = $(this).height() ? $(this).height() : false;
+      var imgmargin = $(this).css('margin');
+      var imgpadding = $(this).css('padding');
 
       // Get caption from title attribute
       var captiontext = $(this).attr('title');
@@ -22,6 +24,9 @@ Drupal.behaviors.image_caption = {
         }
         var style = $(this).attr('style') ? $(this).attr('style') : '';
 
+        // Heights are removed from the style variable here.
+        var style = style.replace(/height.*; /, '')
+
         // Reset img styles as are added to container instead
         $(this).removeAttr('width');
         $(this).removeAttr('height');
@@ -42,6 +47,12 @@ Drupal.behaviors.image_caption = {
         if(imgheight){
           $(this).height(imgheight);
         }
+        if(imgmargin){
+          $(this).parent().css('margin', imgmargin);
+        }
+        if(imgpadding){
+          $(this).parent().css('padding', imgpadding);
+        }
         // Append caption
         $(this).parent().append("<span style=\"display:block;\" class=\"image-caption\">" + captiontext + "</span>");
 
diff --git a/modules/contrib/image_caption/image_caption.min.js b/modules/contrib/image_caption/image_caption.min.js
index e92418b..31d61c5 100644
--- a/modules/contrib/image_caption/image_caption.min.js
+++ b/modules/contrib/image_caption/image_caption.min.js
@@ -1,4 +1,7 @@
-(function($){Drupal.behaviors.image_caption={attach:function(context,settings){$("img.caption:not(.caption-processed)").each(function(i){var imgwidth=$(this).width()?$(this).width():false;var imgheight=$(this).height()?$(this).height():false;var captiontext=$(this).attr('title');if(captiontext){if($(this).attr('align')){var alignment=$(this).attr('align');$(this).css({'float':alignment});$(this).removeAttr('align');}else if($(this).css('float')){var alignment=$(this).css('float');}else{var alignment='normal';}
-var style=$(this).attr('style')?$(this).attr('style'):'';$(this).removeAttr('width');$(this).removeAttr('height');$(this).css('width','');$(this).css('height','');$(this).removeAttr('align');$(this).removeAttr('style');$(this).wrap("<span class=\"image-caption-container\" style=\"display:inline-block;"+style+"\"></span>");$(this).parent().addClass('image-caption-container-'+alignment);if(imgwidth){$(this).width(imgwidth);$(this).parent().width(imgwidth);}
+(function($){Drupal.behaviors.image_caption={attach:function(context,settings){$("img.caption:not(.caption-processed)").each(function(i){var imgwidth=$(this).width()?$(this).width():false;var imgheight=$(this).height()?$(this).height():false;var imgmargin=$(this).css('margin');var imgpadding=$(this).css('padding');var captiontext=$(this).attr('title');if(captiontext){if($(this).attr('align')){var alignment=$(this).attr('align');$(this).css({'float':alignment});$(this).removeAttr('align');}else if($(this).css('float')){var alignment=$(this).css('float');}else{var alignment='normal';}
+var style=$(this).attr('style')?$(this).attr('style'):'';var style=style.replace(/height.*; /,'')
+$(this).removeAttr('width');$(this).removeAttr('height');$(this).css('width','');$(this).css('height','');$(this).removeAttr('align');$(this).removeAttr('style');$(this).wrap("<span class=\"image-caption-container\" style=\"display:inline-block;"+style+"\"></span>");$(this).parent().addClass('image-caption-container-'+alignment);if(imgwidth){$(this).width(imgwidth);$(this).parent().width(imgwidth);}
 if(imgheight){$(this).height(imgheight);}
-$(this).parent().append("<span style=\"display:block;\" class=\"image-caption\">"+captiontext+"</span>");$(this).addClass('caption-processed');}});}};})(jQuery);
+if(imgmargin){$(this).parent().css('margin',imgmargin);}
+if(imgpadding){$(this).parent().css('padding',imgpadding);}
+$(this).parent().append("<span style=\"display:block;\" class=\"image-caption\">"+captiontext+"</span>");$(this).addClass('caption-processed');}});}};})(jQuery);
\ No newline at end of file
