custom user profile covers

v1.18.x
psychobunny 9 years ago
parent 7148d44f90
commit 8e893869ff

@ -140,7 +140,7 @@ helpers.getBaseUser = function(userslug, callerUID, callback) {
results.user.showHidden = results.user.isSelf || results.isAdmin; results.user.showHidden = results.user.isSelf || results.isAdmin;
results.user.profile_links = results.profile_links; 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%'; results['cover:position'] = results['cover:position'] || '50% 50%';
next(null, results.user); next(null, results.user);

@ -72,6 +72,11 @@ profileController.get = function(req, res, callback) {
userData.isFollowing = results.isFollowing; userData.isFollowing = results.isFollowing;
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username}]); userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username}]);
userData.title = 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) { if (!userData.profileviews) {
userData.profileviews = 1; userData.profileviews = 1;
} }

@ -5,11 +5,16 @@ var meta = require('./meta');
var nconf = require('nconf'); var nconf = require('nconf');
coverPhoto.getDefaultCover = function(groupName) { coverPhoto.getDefaultGroupCover = function(groupName) {
return getCover('groups', groupName); return getCover('groups', groupName);
}; };
coverPhoto.getDefaultProfileCover = function(uid) {
return getCover('profile', parseInt(uid, 10));
};
function getCover(type, id) { function getCover(type, id) {
if (meta.config[type + ':defaultCovers']) {
var covers = meta.config[type + ':defaultCovers'].split(/\s*?,\s*?/g); var covers = meta.config[type + ':defaultCovers'].split(/\s*?,\s*?/g);
if (typeof id === 'string') { if (typeof id === 'string') {
@ -18,7 +23,10 @@ function getCover(type, id) {
id = id % covers.length; id = id % covers.length;
} }
return covers && covers.length ? covers[id] : (nconf.get('relative_path') + '/images/cover-default.png'); return covers[id];
}
return nconf.get('relative_path') + '/images/cover-default.png';
} }
module.exports = coverPhoto; module.exports = coverPhoto;

@ -163,7 +163,7 @@ var async = require('async'),
return callback(new Error('[[error:no-group]]')); 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%'; results.base['cover:position'] = results.base['cover:position'] || '50% 50%';
plugins.fireHook('filter:parse.raw', results.base.description, function(err, descriptionParsed) { plugins.fireHook('filter:parse.raw', results.base.description, function(err, descriptionParsed) {

@ -119,6 +119,19 @@
</div> </div>
</div> </div>
<div class="row">
<div class="col-sm-2 col-xs-12 settings-header">Profile Cover</div>
<div class="col-sm-10 col-xs-12">
<form>
<label for="profile:defaultCovers"><strong>Default Cover Images</strong></label>
<p class="help-block">
Add comma-separated default cover images for accounts that don't have an uploaded cover image
</p>
<input type="text" class="form-control input-lg" id="profile:defaultCovers" data-field="profile:defaultCovers" value="{config.relative_path}/images/cover-default.png" placeholder="https://example.com/group1.png, https://example.com/group2.png" />
</form>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-sm-2 col-xs-12 settings-header">Themes</div> <div class="col-sm-2 col-xs-12 settings-header">Themes</div>
<div class="col-sm-10 col-xs-12"> <div class="col-sm-10 col-xs-12">

Loading…
Cancel
Save