diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6
index 24c71dd8fb1..5a475460938 100644
--- a/app/assets/javascripts/discourse/components/composer-editor.js.es6
+++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6
@@ -1014,7 +1014,7 @@ export default Component.extend({
);
// Short upload urls need resolution
- resolveAllShortUrls(ajax);
+ resolveAllShortUrls(ajax, ".d-editor-preview-wrapper");
if (this._enableAdvancedEditorPreviewSync()) {
this._syncScroll(
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6
index 6e6392d7745..213aef39d9a 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6
@@ -145,9 +145,10 @@ function videoHTML(token, opts) {
const src = token.attrGet("src");
const origSrc = token.attrGet("data-orig-src");
const preloadType = opts.secureMedia ? "none" : "metadata";
+ const dataOrigSrcAttr = origSrc !== null ? `data-orig-src="${origSrc}"` : "";
return `
`;
@@ -157,8 +158,9 @@ function audioHTML(token, opts) {
const src = token.attrGet("src");
const origSrc = token.attrGet("data-orig-src");
const preloadType = opts.secureMedia ? "none" : "metadata";
+ const dataOrigSrcAttr = origSrc !== null ? `data-orig-src="${origSrc}"` : "";
return ``;
}
diff --git a/app/assets/javascripts/pretty-text/upload-short-url.js.es6 b/app/assets/javascripts/pretty-text/upload-short-url.js.es6
index b82e524173a..294bae54deb 100644
--- a/app/assets/javascripts/pretty-text/upload-short-url.js.es6
+++ b/app/assets/javascripts/pretty-text/upload-short-url.js.es6
@@ -9,6 +9,11 @@ export function lookupCachedUploadUrl(shortUrl) {
const MISSING = "missing";
export function lookupUncachedUploadUrls(urls, ajax) {
+ urls = _.compact(urls);
+ if (urls.length === 0) {
+ return;
+ }
+
return ajax("/uploads/lookup-urls", {
method: "POST",
data: { short_urls: urls }
@@ -77,7 +82,7 @@ function _loadCachedShortUrls($uploads) {
});
break;
- case "SOURCE": // video tag > source tag
+ case "SOURCE": // video/audio tag > source tag
retrieveCachedUrl($upload, "orig-src", url => {
$upload.attr("src", url);
@@ -85,11 +90,19 @@ function _loadCachedShortUrls($uploads) {
let hostRegex = new RegExp("//" + window.location.host, "g");
url = url.replace(hostRegex, "");
}
- $upload.attr("src", window.location.origin + url);
+ let fullUrl = window.location.origin + url;
+ $upload.attr("src", fullUrl);
// this is necessary, otherwise because of the src change the
- // video just doesn't bother loading!
- $upload.parent()[0].load();
+ // video/audio just doesn't bother loading!
+ let $parent = $upload.parent();
+ $parent[0].load();
+
+ // set the url and text for the tag within the