diff --git a/image_caption.js b/image_caption.js
index 6b9433e..d2bfe58 100644
--- a/image_caption.js
+++ b/image_caption.js
@@ -1,53 +1,58 @@
 (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;
-
+      
       // Get caption from title attribute
       var captiontext = $(this).attr('title');
-
+      if(!(captiontext)) {
+	      var captiontext = '';
+      }
       // Get image alignment and style to apply to container
-      if (captiontext) {
-        if($(this).attr('align')){
-          var alignment = $(this).attr('align');
-          $(this).css({'float':alignment}); // add to css float
-          $(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') : '';
-
-        // Reset img styles as are added to container instead
-        $(this).removeAttr('width');
-        $(this).removeAttr('height');
-        $(this).css('width', '');
-        $(this).css('height', '');
+      if($(this).attr('align')){
+        var alignment = $(this).attr('align');
+        $(this).css({'float':alignment}); // add to css float
         $(this).removeAttr('align');
-        $(this).removeAttr('style');
-
-        //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);
-
-        // Add dimensions, if available
-        if(imgwidth){
-          $(this).width(imgwidth);
-          $(this).parent().width(imgwidth);
-        }
-        if(imgheight){
-          $(this).height(imgheight);
-        }
-        // Append caption
-        $(this).parent().append("<span style=\"display:block;\" class=\"image-caption\">" + captiontext + "</span>");
+      }else if($(this).css('float')){
+        var alignment = $(this).css('float');
+      }else{
+        var alignment = 'normal';
+      }
+      var style = $(this).attr('style') ? $(this).attr('style') : '';
+      if($(this).hasClass('image-thumbnail')){
+	      var imgSize = 'image-thumbnail';
+      } else if($(this).hasClass('image-medium')){
+	      var imgSize = 'image-medium';
+      }
 
-        // Add class to prevent duplicate caption adding
-        $(this).addClass('caption-processed');
+      // Reset img styles as are added to container instead      
+      $(this).removeAttr('width');
+      $(this).removeAttr('height');
+      $(this).css('width', '');
+      $(this).css('height', '');     
+      $(this).removeAttr('align');
+      $(this).removeAttr('style');
+      
+      //Display inline block so it doesn't break any text aligns on the parent contatiner
+      $(this).wrap("<figure class=\"image-caption-container " + imgSize + "\" style=\"display:inline-block;" + style + "\"></figure>");
+      $(this).parent().addClass('image-caption-container-' + alignment);
+      
+      // Add dimensions, if available
+      if(imgwidth){
+        //$(this).width(imgwidth);
+        //$(this).parent().width(imgwidth);
+      }
+      if(imgheight){
+        //$(this).height(imgheight);
       }
+      // Append caption
+      $(this).parent().append("<figcaption class=\"image-caption\">" + captiontext + "</figcaption>");
+      
+      // Add class to prevent duplicate caption adding
+      $(this).addClass('caption-processed');
     });
   }
 };
diff --git a/image_caption.min.js b/image_caption.min.js
index e92418b..d685a25 100644
--- a/image_caption.min.js
+++ b/image_caption.min.js
@@ -1,4 +1,4 @@
-(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);}
-if(imgheight){$(this).height(imgheight);}
-$(this).parent().append("<span style=\"display:block;\" class=\"image-caption\">"+captiontext+"</span>");$(this).addClass('caption-processed');}});}};})(jQuery);
+(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)){var 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';}
+if($(this).hasClass('image-thumbnail')){var imgSize = 'image-thumbnail';}else if($(this).hasClass('image-medium')){var imgSize = 'image-medium';}
+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("<figure class=\"image-caption-container " + imgSize + "\" style=\""+style+"\"></figure>");$(this).parent().addClass('image-caption-container-'+alignment);
+$(this).parent().append("<figcaption class=\"image-caption\">"+captiontext+"</figcaption>");$(this).addClass('caption-processed');});}};})(jQuery);
\ No newline at end of file
