diff options
author | Corey Hulen <corey@hulen.com> | 2015-11-03 13:24:39 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-11-03 13:24:39 -0800 |
commit | 3656ba5344cdaa26a5563323f3fe8cb179fac6dd (patch) | |
tree | a8fc23009f1c4645a4c533f6fcc7b101af0040af /web/react/utils/markdown.jsx | |
parent | 1904a57891d92e84e90c197249fa8497dcee1d9d (diff) | |
parent | b1a8cf6fc56d25b5e3f5425d06c52d379b900ebc (diff) | |
download | chat-3656ba5344cdaa26a5563323f3fe8cb179fac6dd.tar.gz chat-3656ba5344cdaa26a5563323f3fe8cb179fac6dd.tar.bz2 chat-3656ba5344cdaa26a5563323f3fe8cb179fac6dd.zip |
Merge pull request #1290 from mattermost/fixed-embed-height
PLT-991 Fixing height of embeded images
Diffstat (limited to 'web/react/utils/markdown.jsx')
-rw-r--r-- | web/react/utils/markdown.jsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx index 179416ea0..f9416b2de 100644 --- a/web/react/utils/markdown.jsx +++ b/web/react/utils/markdown.jsx @@ -34,6 +34,11 @@ const highlightJsIni = require('highlight.js/lib/languages/ini.js'); const Constants = require('../utils/constants.jsx'); const HighlightedLanguages = Constants.HighlightedLanguages; +function markdownImageLoaded(image) { + image.style.height = 'auto'; +} +window.markdownImageLoaded = markdownImageLoaded; + class MattermostInlineLexer extends marked.InlineLexer { constructor(links, options) { super(links, options); @@ -132,6 +137,16 @@ class MattermostMarkdownRenderer extends marked.Renderer { return super.br(); } + image(href, title, text) { + let out = '<img src="' + href + '" alt="' + text + '"'; + if (title) { + out += ' title="' + title + '"'; + } + out += ' onload="window.markdownImageLoaded(this)" class="markdown-inline-img"'; + out += this.options.xhtml ? '/>' : '>'; + return out; + } + heading(text, level, raw) { const id = `${this.options.headerPrefix}${raw.toLowerCase().replace(/[^\w]+/g, '-')}`; return `<h${level} id="${id}" class="markdown__heading">${text}</h${level}>`; |