FIX[WIP]: return correct path for uploads stored on s3 (#4222)
* return correct path for uploads stored on s3 * rename method
This commit is contained in:
parent
3214e88ce6
commit
6077ac013b
|
@ -249,16 +249,25 @@ Discourse.Utilities = {
|
|||
.join(", ");
|
||||
},
|
||||
|
||||
uploadLocation: function(url) {
|
||||
if (Discourse.CDN) {
|
||||
return Discourse.CDN.startsWith('//') ? "http:" + Discourse.getURLWithCDN(url) : Discourse.getURLWithCDN(url);
|
||||
} else if (Discourse.SiteSettings.enable_s3_uploads) {
|
||||
return 'https:' + url;
|
||||
} else {
|
||||
var protocol = window.location.protocol + '//',
|
||||
hostname = window.location.hostname,
|
||||
port = ':' + window.location.port;
|
||||
return protocol + hostname + port + url;
|
||||
}
|
||||
},
|
||||
|
||||
getUploadMarkdown: function(upload) {
|
||||
if (Discourse.Utilities.isAnImage(upload.original_filename)) {
|
||||
return '<img src="' + upload.url + '" width="' + upload.width + '" height="' + upload.height + '">';
|
||||
} else if (!Discourse.SiteSettings.prevent_anons_from_downloading_files && (/\.(mov|mp4|webm|ogv|mp3|ogg|wav)$/i).test(upload.original_filename)) {
|
||||
// is Audio/Video
|
||||
if (Discourse.CDN) {
|
||||
return Discourse.CDN.startsWith('//') ? "http:" + Discourse.getURLWithCDN(upload.url) : Discourse.getURLWithCDN(upload.url);
|
||||
} else {
|
||||
return "http://" + Discourse.BaseUrl + upload.url;
|
||||
}
|
||||
return Discourse.Utilities.uploadLocation(upload.url);
|
||||
} else {
|
||||
return '<a class="attachment" href="' + upload.url + '">' + upload.original_filename + '</a> (' + I18n.toHumanSize(upload.filesize) + ')';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue