diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js index 63a25a992a..a34d0df40d 100644 --- a/src/controllers/accounts/helpers.js +++ b/src/controllers/accounts/helpers.js @@ -140,7 +140,7 @@ helpers.getBaseUser = function(userslug, callerUID, callback) { results.user.showHidden = results.user.isSelf || results.isAdmin; results.user.profile_links = results.profile_links; - results['cover:url'] = results['cover:url'] || nconf.get('relative_path') + '/images/cover-default.png'; + results['cover:url'] = results['cover:url'] || require('../../coverPhoto').getDefaultProfileCover(results.user.uid); results['cover:position'] = results['cover:position'] || '50% 50%'; next(null, results.user); diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js index e55ee0d157..40d7fe5367 100644 --- a/src/controllers/accounts/profile.js +++ b/src/controllers/accounts/profile.js @@ -72,6 +72,11 @@ profileController.get = function(req, res, callback) { userData.isFollowing = results.isFollowing; userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username}]); userData.title = userData.username; + + userData['cover:url'] = userData['cover:url'] || require('../../coverPhoto').getDefaultProfileCover(userData.uid); + userData['cover:position'] = userData['cover:position'] || '50% 50%'; + console.log(userData['cover:url']); + if (!userData.profileviews) { userData.profileviews = 1; } diff --git a/src/coverPhoto.js b/src/coverPhoto.js index 137d0e0078..d699ace785 100644 --- a/src/coverPhoto.js +++ b/src/coverPhoto.js @@ -5,20 +5,28 @@ var meta = require('./meta'); var nconf = require('nconf'); -coverPhoto.getDefaultCover = function(groupName) { +coverPhoto.getDefaultGroupCover = function(groupName) { return getCover('groups', groupName); }; +coverPhoto.getDefaultProfileCover = function(uid) { + return getCover('profile', parseInt(uid, 10)); +}; + function getCover(type, id) { - var covers = meta.config[type + ':defaultCovers'].split(/\s*?,\s*?/g); - - if (typeof id === 'string') { - id = (id.charCodeAt(0) + id.charCodeAt(1)) % covers.length; - } else { - id = id % covers.length; + if (meta.config[type + ':defaultCovers']) { + var covers = meta.config[type + ':defaultCovers'].split(/\s*?,\s*?/g); + + if (typeof id === 'string') { + id = (id.charCodeAt(0) + id.charCodeAt(1)) % covers.length; + } else { + id = id % covers.length; + } + + return covers[id]; } - return covers && covers.length ? covers[id] : (nconf.get('relative_path') + '/images/cover-default.png'); + return nconf.get('relative_path') + '/images/cover-default.png'; } module.exports = coverPhoto; \ No newline at end of file diff --git a/src/groups.js b/src/groups.js index 246ca618eb..ab0be677a9 100644 --- a/src/groups.js +++ b/src/groups.js @@ -163,7 +163,7 @@ var async = require('async'), return callback(new Error('[[error:no-group]]')); } - results.base['cover:url'] = results.base['cover:url'] || require('./coverPhoto').getDefaultCover(groupName); + results.base['cover:url'] = results.base['cover:url'] || require('./coverPhoto').getDefaultGroupCover(groupName); results.base['cover:position'] = results.base['cover:position'] || '50% 50%'; plugins.fireHook('filter:parse.raw', results.base.description, function(err, descriptionParsed) { diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tpl index f5cc3884ee..dab4ea1196 100644 --- a/src/views/admin/settings/user.tpl +++ b/src/views/admin/settings/user.tpl @@ -119,6 +119,19 @@ +
+
Profile Cover
+
+
+ +

+ Add comma-separated default cover images for accounts that don't have an uploaded cover image +

+ +
+
+
+
Themes