diff --git a/helpers/parse_image_size.js b/helpers/parse_image_size.js
index 3b1fc2f984e4dc219da0c8ec72834a0a03047b95..16e3f028a8af32062e7eddce54bb75de99297e05 100644
--- a/helpers/parse_image_size.js
+++ b/helpers/parse_image_size.js
@@ -46,7 +46,7 @@ module.exports = function parseImageSize(str, pos, max) {
   // (2) =300x
   // (3) =x200
   code = str.charCodeAt(pos);
-  if (code !== 0x78 /* x */ && (code < 0x30 && code  > 0x39) /* [0-9] */) {
+  if (code !== 0x78 /* x */ && (code < 0x30 || code  > 0x39) /* [0-9] */) {
     return result;
   }
 
diff --git a/index.js b/index.js
index 5eb9a1180ceea3bd26b4eb6949617745bc892f87..2254e704d0126796b6d9b3da55f008638d7afca0 100644
--- a/index.js
+++ b/index.js
@@ -41,7 +41,7 @@ function image_with_size(md) {
       //
 
       // [link](  <href>  "title"  )
-      //    ^^ skipping these spaces
+      //        ^^ skipping these spaces
       pos++;
       for (; pos < max; pos++) {
         code = state.src.charCodeAt(pos);
@@ -50,7 +50,7 @@ function image_with_size(md) {
       if (pos >= max) { return false; }
 
       // [link](  <href>  "title"  )
-      //      ^^^^^^ parsing link destination
+      //          ^^^^^^ parsing link destination
       start = pos;
       res = md.helpers.parseLinkDestination(state.src, pos, state.posMax);
       if (res.ok && state.md.inline.validateLink(res.str)) {
@@ -61,7 +61,7 @@ function image_with_size(md) {
       }
 
       // [link](  <href>  "title"  )
-      //        ^^ skipping these spaces
+      //                ^^ skipping these spaces
       start = pos;
       for (; pos < max; pos++) {
         code = state.src.charCodeAt(pos);
@@ -69,14 +69,14 @@ function image_with_size(md) {
       }
 
       // [link](  <href>  "title"  )
-      //          ^^^^^^^ parsing link title
+      //                  ^^^^^^^ parsing link title
       res = md.helpers.parseLinkTitle(state.src, pos, state.posMax);
       if (pos < max && start !== pos && res.ok) {
         title = res.str;
         pos = res.pos;
 
         // [link](  <href>  "title"  )
-        //             ^^ skipping these spaces
+        //                         ^^ skipping these spaces
         for (; pos < max; pos++) {
           code = state.src.charCodeAt(pos);
           if (code !== 0x20 && code !== 0x0A) { break; }
@@ -86,7 +86,7 @@ function image_with_size(md) {
       }
 
       // [link](  <href>  "title" =WxH  )
-      //              ^^^^ parsing image size
+      //                          ^^^^ parsing image size
       if (pos - 1 >= 0) {
         code = state.src.charCodeAt(pos - 1);
 
@@ -100,7 +100,7 @@ function image_with_size(md) {
             pos = res.pos;
 
             // [link](  <href>  "title" =WxH  )
-            //                ^^ skipping these spaces
+            //                              ^^ skipping these spaces
             for (; pos < max; pos++) {
               code = state.src.charCodeAt(pos);
               if (code !== 0x20 && code !== 0x0A) { break; }
@@ -122,7 +122,7 @@ function image_with_size(md) {
       if (typeof state.env.references === 'undefined') { return false; }
 
       // [foo]  [bar]
-      //    ^^ optional whitespace (can include newlines)
+      //      ^^ optional whitespace (can include newlines)
       for (; pos < max; pos++) {
         code = state.src.charCodeAt(pos);
         if (code !== 0x20 && code !== 0x0A) { break; }
diff --git a/test/fixtures/imsize.txt b/test/fixtures/imsize.txt
index 06c9b998eac803c083009d85b745c1aa7689d4e3..ff83718a5e6c1a5a9b11535f84f24223d2d5ba1c 100644
--- a/test/fixtures/imsize.txt
+++ b/test/fixtures/imsize.txt
@@ -258,6 +258,26 @@ Coverage. Image
 .
 <p>![test]( x = 100x200 )</p>
 .
+.
+![test]( x =aaaxbbb )
+.
+<p>![test]( x =aaaxbbb )</p>
+.
+.
+![test](http://this.is.test.jpg =100x200)
+.
+<p><img src="http://this.is.test.jpg" alt="test" width="100" height="200"></p>
+.
+.
+![test](<x =100x200)
+.
+<p>![test](&lt;x =100x200)</p>
+.
+.
+![test](<x> =100x200)
+.
+<p><img src="x" alt="test" width="100" height="200"></p>
+.
 
 Coverage. Link
 .