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;
|
||||
},
|
||||
|
||||
getURLWithCDN: function(url) {
|
||||
url = this.getURL(url);
|
||||
if (Discourse.CDN) { url = Discourse.CDN + url; }
|
||||
return url;
|
||||
},
|
||||
|
||||
Resolver: DiscourseResolver,
|
||||
|
||||
_titleChanged: function() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var esc = Handlebars.Utils.escapeExpression;
|
||||
|
||||
Discourse.BBCode.register('quote', {noWrap: true, singlePara: true}, function(contents, bbParams, options) {
|
||||
var params = {'class': 'quote'},
|
||||
username = null;
|
||||
|
|
|
@ -51,7 +51,7 @@ Discourse.Utilities = {
|
|||
|
||||
var classes = "avatar" + (options.extraClasses ? " " + options.extraClasses : "");
|
||||
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) {
|
||||
|
|
|
@ -72,10 +72,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
@type {String}
|
||||
**/
|
||||
profileBackground: function() {
|
||||
var background = this.get('profile_background');
|
||||
if(Em.isEmpty(background) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
|
||||
|
||||
return 'background-image: url(' + background + ')';
|
||||
var url = this.get('profile_background');
|
||||
if (Em.isEmpty(url) || !Discourse.SiteSettings.allow_profile_backgrounds) { return; }
|
||||
return 'background-image: url(' + Discourse.getURLWithCDN(url) + ')';
|
||||
}.property('profile_background'),
|
||||
|
||||
/**
|
||||
|
@ -442,6 +441,7 @@ Discourse.User.reopenClass(Discourse.Singleton, {
|
|||
|
||||
avatarTemplate: function(username, uploadedAvatarId) {
|
||||
var url;
|
||||
|
||||
if (uploadedAvatarId) {
|
||||
url = "/user_avatar/" +
|
||||
Discourse.BaseUrl +
|
||||
|
@ -456,11 +456,7 @@ Discourse.User.reopenClass(Discourse.Singleton, {
|
|||
Discourse.LetterAvatarVersion + ".png";
|
||||
}
|
||||
|
||||
url = Discourse.getURL(url);
|
||||
if (Discourse.CDN) {
|
||||
url = Discourse.CDN + url;
|
||||
}
|
||||
return url;
|
||||
return Discourse.getURLWithCDN(url);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,7 @@ export default Discourse.View.extend(CleansUp, {
|
|||
|
||||
addBackground: function() {
|
||||
var url = this.get('controller.user.card_background');
|
||||
|
||||
if (!this.get('allowBackgrounds')) { return; }
|
||||
|
||||
var $this = this.$();
|
||||
|
@ -19,7 +20,7 @@ export default Discourse.View.extend(CleansUp, {
|
|||
if (Ember.isEmpty(url)) {
|
||||
$this.css('background-image', '').addClass('no-bg');
|
||||
} 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'),
|
||||
|
||||
|
|
Loading…
Reference in New Issue