mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:36:42 +08:00
UX: Style video elements, show descriptions (#10040)
It's a stop gap – ideally we would generate a thumbnail for uploaded videos. For now, a bit of intentionality in the style and a pinch of context should do.
This commit is contained in:
parent
a859d507e7
commit
7d289a4f3e
|
@ -147,6 +147,7 @@ function videoHTML(token, opts) {
|
|||
const preloadType = opts.secureMedia ? "none" : "metadata";
|
||||
const dataOrigSrcAttr = origSrc !== null ? `data-orig-src="${origSrc}"` : "";
|
||||
return `<div class="video-container">
|
||||
<p class="video-description">${opts.alt}</p>
|
||||
<video width="100%" height="100%" preload="${preloadType}" controls>
|
||||
<source src="${src}" ${dataOrigSrcAttr}>
|
||||
<a href="${src}">${src}</a>
|
||||
|
@ -176,7 +177,8 @@ function renderImageOrPlayableMedia(tokens, idx, options, env, slf) {
|
|||
// see https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer
|
||||
// handles |video and |audio alt transformations for image tags
|
||||
const mediaOpts = {
|
||||
secureMedia: options.discourse.limitedSiteSettings.secureMedia
|
||||
secureMedia: options.discourse.limitedSiteSettings.secureMedia,
|
||||
alt: split[0]
|
||||
};
|
||||
if (split[1] === "video") {
|
||||
return videoHTML(token, mediaOpts);
|
||||
|
|
|
@ -185,6 +185,7 @@ export const DEFAULT_LIST = [
|
|||
"span.excerpt",
|
||||
"div.excerpt",
|
||||
"div.video-container",
|
||||
"p.video-description",
|
||||
"span.hashtag",
|
||||
"span.mention",
|
||||
"strike",
|
||||
|
|
|
@ -703,6 +703,9 @@ aside.onebox.stackexchange .onebox-body {
|
|||
// Force oneboxed videos to 16:9 aspect ratio
|
||||
.onebox.video-onebox,
|
||||
.video-container {
|
||||
background: $primary-very-low;
|
||||
border: 1px solid $primary-low;
|
||||
border-radius: 2px;
|
||||
position: relative;
|
||||
padding: 0 0 56.25% 0;
|
||||
width: 100%;
|
||||
|
@ -714,6 +717,12 @@ aside.onebox.stackexchange .onebox-body {
|
|||
}
|
||||
}
|
||||
|
||||
.video-description {
|
||||
color: $primary-medium;
|
||||
margin: 1rem;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.onebox-placeholder-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
|
|
@ -1030,6 +1030,7 @@ QUnit.test("video - secure media enabled", assert => {
|
|||
"![baby shark|video](upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4)",
|
||||
{ siteSettings: { secure_media: true } },
|
||||
`<p><div class="video-container">
|
||||
<p class="video-description">baby shark</p>
|
||||
<video width="100%" height="100%" preload="none" controls>
|
||||
<source src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4">
|
||||
<a href="/404">/404</a>
|
||||
|
@ -1055,6 +1056,7 @@ QUnit.test("video", assert => {
|
|||
assert.cooked(
|
||||
"![baby shark|video](upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4)",
|
||||
`<p><div class="video-container">
|
||||
<p class="video-description">baby shark</p>
|
||||
<video width="100%" height="100%" preload="metadata" controls>
|
||||
<source src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4">
|
||||
<a href="/404">/404</a>
|
||||
|
@ -1081,6 +1083,7 @@ QUnit.test("video - mapped url - secure media enabled", assert => {
|
|||
lookupUploadUrls: lookupUploadUrls
|
||||
},
|
||||
`<p><div class="video-container">
|
||||
<p class="video-description">baby shark</p>
|
||||
<video width="100%" height="100%" preload="none" controls>
|
||||
<source src="/secure-media-uploads/original/3X/c/b/test.mp4">
|
||||
<a href="/secure-media-uploads/original/3X/c/b/test.mp4">/secure-media-uploads/original/3X/c/b/test.mp4</a>
|
||||
|
|
Loading…
Reference in New Issue
Block a user