Fixing height of embeded images

Этот коммит содержится в:
Christopher Speller
2015-11-03 15:39:40 -05:00
родитель c68e53aa23
Коммит b1a8cf6fc5
5 изменённых файлов: 34 добавлений и 3 удалений

Просмотреть файл

@@ -77,12 +77,12 @@ export default class PostBody extends React.Component {
this.isGifLoading = true; this.isGifLoading = true;
const gif = new Image(); const gif = new Image();
gif.src = src;
gif.onload = ( gif.onload = (
() => { () => {
this.setState({gifLoaded: true}); this.setState({gifLoaded: true});
} }
); );
gif.src = src;
} }
createGifEmbed(link) { createGifEmbed(link) {
@@ -92,7 +92,12 @@ export default class PostBody extends React.Component {
if (!this.state.gifLoaded) { if (!this.state.gifLoaded) {
this.loadGif(link); this.loadGif(link);
return null; return (
<img
className='gif-div placeholder'
height='500px'
/>
);
} }
return ( return (

Просмотреть файл

@@ -34,6 +34,11 @@ const highlightJsIni = require('highlight.js/lib/languages/ini.js');
const Constants = require('../utils/constants.jsx'); const Constants = require('../utils/constants.jsx');
const HighlightedLanguages = Constants.HighlightedLanguages; const HighlightedLanguages = Constants.HighlightedLanguages;
function markdownImageLoaded(image) {
image.style.height = 'auto';
}
window.markdownImageLoaded = markdownImageLoaded;
class MattermostInlineLexer extends marked.InlineLexer { class MattermostInlineLexer extends marked.InlineLexer {
constructor(links, options) { constructor(links, options) {
super(links, options); super(links, options);
@@ -132,6 +137,16 @@ class MattermostMarkdownRenderer extends marked.Renderer {
return super.br(); 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) { heading(text, level, raw) {
const id = `${this.options.headerPrefix}${raw.toLowerCase().replace(/[^\w]+/g, '-')}`; const id = `${this.options.headerPrefix}${raw.toLowerCase().replace(/[^\w]+/g, '-')}`;
return `<h${level} id="${id}" class="markdown__heading">${text}</h${level}>`; return `<h${level} id="${id}" class="markdown__heading">${text}</h${level}>`;

Просмотреть файл

@@ -1,5 +1,6 @@
#channel-header { #channel-header {
padding: 3px 0; padding: 3px 0;
height: 58px;
} }
.row { .row {
&.header { &.header {
@@ -42,6 +43,9 @@
text-overflow: ellipsis; text-overflow: ellipsis;
margin-top: 2px; margin-top: 2px;
max-height: 45px; max-height: 45px;
.markdown-inline-img {
max-height: 45px
}
} }
&.popover { &.popover {
white-space: normal; white-space: normal;

Просмотреть файл

@@ -8,6 +8,10 @@
margin-left: 4px; margin-left: 4px;
} }
} }
.markdown-inline-img {
max-height: 500px;
height: 500px;
}
.post-body { .post-body {
hr { hr {
height: 4px; height: 4px;

Просмотреть файл

@@ -56,5 +56,8 @@
max-width: 450px; max-width: 450px;
max-height: 500px; max-height: 500px;
margin-bottom: 8px; margin-bottom: 8px;
border-radius:5px border-radius:5px;
&.placeholder {
height: 500px;
}
} }