Skip to content

Instantly share code, notes, and snippets.

@deedubs
Forked from shinecita/backend
Last active December 11, 2015 11:38
Show Gist options
  • Save deedubs/4595292 to your computer and use it in GitHub Desktop.
Save deedubs/4595292 to your computer and use it in GitHub Desktop.
// Gets user avatar url
router.get('/:userId/avatar', function(req, res) {
console.log("User", req.user.pictureUrl);
if (req.user.pictureUrl) {
console.log("redirecting avatar")
res.redirect(req.user.pictureUrl)
} else {
console.log("redirecting default")
res.redirect('/img/userProfileAvatar.png')
}
})
<div class="span6" id="activities">
<h3 class="span2">Activity</h3>
<img ng-src="{{activities[0].actor.avatar()}}" />
User.prototype.avatar = function() {
return "/users/" + this._id + "/avatar";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment