mirror of
https://github.com/discourse/discourse.git
synced 2025-06-11 07:23:43 +08:00
FEATURE: Use upload:// short URL for videos and audio in composer (#8760)
For consistency this PR introduces using custom markdown and short upload:// URLs for video and audio uploads, rather than just treating them as links and relying on the oneboxer. The markdown syntax for videos is  and for audio it is . This is achieved in discourse-markdown-it by modifying the rules for images in mardown-it via md.renderer.rules.image. We return HTML instead of the token when we encounter audio or video after | and the preview renders that HTML. Also when uploading an audio or video file we insert the relevant markdown into the composer.
This commit is contained in:
@ -33,9 +33,22 @@ QUnit.module("lib:pretty-text/upload-short-url", {
|
||||
}
|
||||
];
|
||||
|
||||
const otherMediaSrcs = [
|
||||
{
|
||||
short_url: "upload://d.mp4",
|
||||
url: "/uploads/default/original/3X/c/b/4.mp4",
|
||||
short_path: "/uploads/short-url/d.mp4"
|
||||
},
|
||||
{
|
||||
short_url: "upload://e.mp3",
|
||||
url: "/uploads/default/original/3X/c/b/5.mp3",
|
||||
short_path: "/uploads/short-url/e.mp3"
|
||||
}
|
||||
];
|
||||
|
||||
// prettier-ignore
|
||||
server.post("/uploads/lookup-urls", () => { //eslint-disable-line
|
||||
return response(imageSrcs.concat(attachmentSrcs));
|
||||
return response(imageSrcs.concat(attachmentSrcs.concat(otherMediaSrcs)));
|
||||
});
|
||||
|
||||
fixture().html(
|
||||
@ -79,4 +92,16 @@ QUnit.test("resolveAllShortUrls", async assert => {
|
||||
url: "/uploads/default/original/3X/c/b/3.pdf",
|
||||
short_path: "/uploads/short-url/c.pdf"
|
||||
});
|
||||
|
||||
lookup = lookupCachedUploadUrl("upload://d.mp4");
|
||||
assert.deepEqual(lookup, {
|
||||
url: "/uploads/default/original/3X/c/b/4.mp4",
|
||||
short_path: "/uploads/short-url/d.mp4"
|
||||
});
|
||||
|
||||
lookup = lookupCachedUploadUrl("upload://e.mp3");
|
||||
assert.deepEqual(lookup, {
|
||||
url: "/uploads/default/original/3X/c/b/5.mp3",
|
||||
short_path: "/uploads/short-url/e.mp3"
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user