Merge pull request #1479 from alectrocute/fix-video-embeds-on-posts

This commit is contained in:
SleeplessOne1917 2023-06-22 19:13:38 +00:00 committed by GitHub
commit f5b958f884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -239,7 +239,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
} }
get img() { get img() {
return this.imageSrc ? ( if (this.imageSrc) {
return (
<> <>
<div className="offset-sm-3 my-2 d-none d-sm-block"> <div className="offset-sm-3 my-2 d-none d-sm-block">
<a href={this.imageSrc} className="d-inline-block"> <a href={this.imageSrc} className="d-inline-block">
@ -255,11 +256,25 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
</a> </a>
</div> </div>
</> </>
) : (
<></>
); );
} }
const { post } = this.postView;
const { url } = post;
if (url && isVideo(url)) {
return (
<div className="embed-responsive mt-3">
<video muted controls className="embed-responsive-item col-12">
<source src={url} type="video/mp4" />
</video>
</div>
);
}
return <></>;
}
imgThumb(src: string) { imgThumb(src: string) {
const post_view = this.postView; const post_view = this.postView;
return ( return (
@ -325,17 +340,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
} else if (url) { } else if (url) {
if (!this.props.hideImage && isVideo(url)) { if (!this.props.hideImage && isVideo(url)) {
return ( return (
<div className="embed-responsive embed-responsive-16by9"> <a
<video className="text-body"
playsInline href={url}
muted title={url}
loop rel={relTags}
controls data-tippy-content={I18NextService.i18n.t("expand_here")}
className="embed-responsive-item" onClick={linkEvent(this, this.handleImageExpandClick)}
aria-label={I18NextService.i18n.t("expand_here")}
> >
<source src={url} type="video/mp4" /> <div className="thumbnail rounded bg-light d-flex justify-content-center">
</video> <Icon icon="play" classes="d-flex align-items-center" />
</div> </div>
</a>
); );
} else { } else {
return ( return (