diff --git a/app/assets/javascripts/discourse/lib/to-markdown.js.es6 b/app/assets/javascripts/discourse/lib/to-markdown.js.es6
index c20a738d3ea..67b4929c8fa 100644
--- a/app/assets/javascripts/discourse/lib/to-markdown.js.es6
+++ b/app/assets/javascripts/discourse/lib/to-markdown.js.es6
@@ -125,12 +125,19 @@ class Tag {
 
       toMarkdown() {
         const e = this.element;
-        const attr = e.attributes;
-        const pAttr = e.parent && e.parent.attributes;
-        const src = (attr && attr.src) || (pAttr && pAttr.src);
+        const attr = e.attributes || {};
+        const pAttr = (e.parent && e.parent.attributes) || {};
+        const src = attr.src || pAttr.src;
 
         if (src) {
-          const alt = (attr && attr.alt) || (pAttr && pAttr.alt) || "";
+          let alt = attr.alt || pAttr.alt || "";
+          const width = attr.width || pAttr.width;
+          const height = attr.height || pAttr.height;
+
+          if (width && height) {
+            alt = `${alt}|${width}x${height}`;
+          }
+
           return "![" + alt + "](" + src + ")";
         }
 
diff --git a/test/javascripts/lib/to-markdown-test.js.es6 b/test/javascripts/lib/to-markdown-test.js.es6
index 96ee32db5ac..b35a1fbc560 100644
--- a/test/javascripts/lib/to-markdown-test.js.es6
+++ b/test/javascripts/lib/to-markdown-test.js.es6
@@ -106,11 +106,11 @@ QUnit.test("converts table as readable", assert => {
 
 QUnit.test("converts img tag", assert => {
   const url = "https://example.com/image.png";
-  let html = `<img src="${url}">`;
-  assert.equal(toMarkdown(html), `![](${url})`);
+  let html = `<img src="${url}" width="100" height="50">`;
+  assert.equal(toMarkdown(html), `![|100x50](${url})`);
 
-  html = `<div><span><img src="${url}" alt="description" /></span></div>`;
-  assert.equal(toMarkdown(html), `![description](${url})`);
+  html = `<div><span><img src="${url}" alt="description" width="50" height="100" /></span></div>`;
+  assert.equal(toMarkdown(html), `![description|50x100](${url})`);
 
   html = `<a href="http://example.com"><img src="${url}" alt="description" /></a>`;
   assert.equal(toMarkdown(html), `[![description](${url})](http://example.com)`);