summaryrefslogtreecommitdiffstats
path: root/web/react/components/post_attachment_oembed.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/components/post_attachment_oembed.jsx')
-rw-r--r--web/react/components/post_attachment_oembed.jsx35
1 files changed, 24 insertions, 11 deletions
diff --git a/web/react/components/post_attachment_oembed.jsx b/web/react/components/post_attachment_oembed.jsx
index f544dbc88..13c32f744 100644
--- a/web/react/components/post_attachment_oembed.jsx
+++ b/web/react/components/post_attachment_oembed.jsx
@@ -20,8 +20,11 @@ export default class PostAttachmentOEmbed extends React.Component {
fetchData(link) {
if (!this.isLoading) {
this.isLoading = true;
+ let url = 'https://noembed.com/embed?nowrap=on';
+ url += '&url=' + encodeURIComponent(link);
+ url += '&maxheight=' + this.props.provider.height;
return $.ajax({
- url: 'https://noembed.com/embed?nowrap=on&url=' + encodeURIComponent(link),
+ url,
dataType: 'jsonp',
success: (result) => {
this.isLoading = false;
@@ -39,8 +42,18 @@ export default class PostAttachmentOEmbed extends React.Component {
}
render() {
+ let data = {};
+ let content;
if ($.isEmptyObject(this.state.data)) {
- return <div></div>;
+ content = <div style={{height: this.props.provider.height}}/>;
+ } else {
+ data = this.state.data;
+ content = (
+ <div
+ style={{height: this.props.provider.height}}
+ dangerouslySetInnerHTML={{__html: data.html}}
+ />
+ );
}
return (
@@ -57,18 +70,17 @@ export default class PostAttachmentOEmbed extends React.Component {
>
<a
className='attachment__title-link'
- href={this.state.data.url}
+ href={data.url}
target='_blank'
>
- {this.state.data.title}
+ {data.title}
</a>
</h1>
- <div>
- <div className={'attachment__body attachment__body--no_thumb'}>
- <div
- dangerouslySetInnerHTML={{__html: this.state.data.html}}
- >
- </div>
+ <div >
+ <div
+ className={'attachment__body attachment__body--no_thumb'}
+ >
+ {content}
</div>
</div>
</div>
@@ -79,5 +91,6 @@ export default class PostAttachmentOEmbed extends React.Component {
}
PostAttachmentOEmbed.propTypes = {
- link: React.PropTypes.string.isRequired
+ link: React.PropTypes.string.isRequired,
+ provider: React.PropTypes.object.isRequired
};