diff --git a/image_caption.js b/image_caption.js
index 5daf4e5..81c470c 100644
--- a/image_caption.js
+++ b/image_caption.js
@@ -1,18 +1,35 @@
+/*$Id: image_caption.js,v 1.2.2.3 2010/02/03 07:50:25 davidwhthomas Exp $*/
 $(document).ready(function(){
   $("img.caption").each(function(i) {
     var imgwidth = $(this).width();
     var imgheight = $(this).height();
+    
+    //We need to remove height and width from the style and attributes so it doesn't get added to the contatiner.
+    $(this).removeAttr('width');
+    $(this).removeAttr('height');
+    $(this).css('width', '');
+    $(this).css('height', '');
+    
     var captiontext = $(this).attr('title');
     var style = $(this).attr('style');
     var alignment = $(this).attr('align');
+    
     //Clear image styles to prevent conflicts with parent div
     $(this).attr({align:""});
     $(this).attr({style:""});
-    $(this).wrap("<span class=\"image-caption-container\" style=\"display:block;" + style + "; float: " + alignment + "\"></span>");
+    
+    //Make sure that the height and width get added back to the image so the image doesn't blow up
+    $(this).width(imgwidth);
+    $(this).height(imgheight);
+    
+    //Display inline block so it doesn't break any text aligns on the parent contatiner
+    $(this).wrap("<span class=\"image-caption-container\" style=\"display:inline-block;" + style + "\"></span>");
     $(this).parent().addClass('image-caption-container-' + alignment);
+    
     if(imgwidth != 'undefined' && imgwidth != 0){
       $(this).parent().width(imgwidth);
     }
+    
     $(this).parent().append("<span style=\"display:block;\" class=\"image-caption\">" + captiontext + "</span>");
   });
-});
\ No newline at end of file
+});
