FIX: use CDN for user card/profile background and user avatars
This commit is contained in:
parent
e42e9bd010
commit
14dc22f288
|
@ -24,6 +24,12 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
||||||
return u + url;
|
return u + url;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getURLWithCDN: function(url) {
|
||||||
|
url = this.getURL(url);
|
||||||
|
if (Discourse.CDN) { url = Discourse.CDN + url; }
|
||||||
|
return url;
|
||||||
|
},
|
||||||
|
|
||||||
Resolver: DiscourseResolver,
|
Resolver: DiscourseResolver,
|
||||||
|
|
||||||
_titleChanged: function() {
|
_titleChanged: function() {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var esc = Handlebars.Utils.escapeExpression;
|
var esc = Handlebars.Utils.escapeExpression;
|
||||||
|
|
||||||
Discourse.BBCode.register('quote', {noWrap: true, singlePara: true}, function(contents, bbParams, options) {
|
Discourse.BBCode.register('quote', {noWrap: true, singlePara: true}, function(contents, bbParams, options) {
|
||||||
var params = {'class': 'quote'},
|
var params = {'class': 'quote'},
|
||||||
username = null;
|
username = null;
|
||||||
|
|
|
@ -51,7 +51,7 @@ Discourse.Utilities = {
|
||||||
|
|
||||||
var classes = "avatar" + (options.extraClasses ? " " + options.extraClasses : "");
|
var classes = "avatar" + (options.extraClasses ? " " + options.extraClasses : "");
|
||||||
var title = (options.title) ? " title='" + Handlebars.Utils.escapeExpression(options.title || "") + "'" : "";
|
var title = (options.title) ? " title='" + Handlebars.Utils.escapeExpression(options.title || "") + "'" : "";
|
||||||
return "<img width='" + size + "' height='" + size + "' src='" + url + "' class='" + classes + "'" + title + ">";
|
return "<img width='" + size + "' height='" + size + "' src='" + Discourse.getURLWithCDN(url) + "' class='" + classes + "'" + title + ">";
|
||||||
},
|
},
|
||||||
|
|
||||||
tinyAvatar: function(avatarTemplate, options) {
|
tinyAvatar: function(avatarTemplate, options) {
|
||||||
|
|
|
@ -72,10 +72,9 @@ Discourse.User = Discourse.Model.extend({
|
||||||
@type {String}
|
@type {String}
|
||||||
**/
|
**/
|
||||||
profileBackground: function() {
|
profileBackground: function() {
|
||||||
var background = this.get('profile_background');
|
var url = this.get('profile_background');
|
||||||
if(Em.isEmpty(background) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
|
if (Em.isEmpty(url) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
|
||||||
|
return 'background-image: url(' + Discourse.getURLWithCDN(url) + ')';
|
||||||
return 'background-image: url(' + background + ')';
|
|
||||||
}.property('profile_background'),
|
}.property('profile_background'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,6 +441,7 @@ Discourse.User.reopenClass(Discourse.Singleton, {
|
||||||
|
|
||||||
avatarTemplate: function(username, uploadedAvatarId) {
|
avatarTemplate: function(username, uploadedAvatarId) {
|
||||||
var url;
|
var url;
|
||||||
|
|
||||||
if (uploadedAvatarId) {
|
if (uploadedAvatarId) {
|
||||||
url = "/user_avatar/" +
|
url = "/user_avatar/" +
|
||||||
Discourse.BaseUrl +
|
Discourse.BaseUrl +
|
||||||
|
@ -456,11 +456,7 @@ Discourse.User.reopenClass(Discourse.Singleton, {
|
||||||
Discourse.LetterAvatarVersion + ".png";
|
Discourse.LetterAvatarVersion + ".png";
|
||||||
}
|
}
|
||||||
|
|
||||||
url = Discourse.getURL(url);
|
return Discourse.getURLWithCDN(url);
|
||||||
if (Discourse.CDN) {
|
|
||||||
url = Discourse.CDN + url;
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,6 +11,7 @@ export default Discourse.View.extend(CleansUp, {
|
||||||
|
|
||||||
addBackground: function() {
|
addBackground: function() {
|
||||||
var url = this.get('controller.user.card_background');
|
var url = this.get('controller.user.card_background');
|
||||||
|
|
||||||
if (!this.get('allowBackgrounds')) { return; }
|
if (!this.get('allowBackgrounds')) { return; }
|
||||||
|
|
||||||
var $this = this.$();
|
var $this = this.$();
|
||||||
|
@ -19,7 +20,7 @@ export default Discourse.View.extend(CleansUp, {
|
||||||
if (Ember.isEmpty(url)) {
|
if (Ember.isEmpty(url)) {
|
||||||
$this.css('background-image', '').addClass('no-bg');
|
$this.css('background-image', '').addClass('no-bg');
|
||||||
} else {
|
} else {
|
||||||
$this.css('background-image', "url(" + url + ")").removeClass('no-bg');
|
$this.css('background-image', "url(" + Discourse.getURLWithCDN(url) + ")").removeClass('no-bg');
|
||||||
}
|
}
|
||||||
}.observes('controller.user.card_background'),
|
}.observes('controller.user.card_background'),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue