Files: 8ec3c173cbb66e5cd3c3866431ffd5883c151db2 / modules / avatar-image.js
686 bytesRaw
1 | |
2 | var getAvatar = require('ssb-avatar') |
3 | var h = require('hyperscript') |
4 | var ref = require('ssb-ref') |
5 | |
6 | var plugs = require('../plugs') |
7 | var sbot_whoami = plugs.first(exports.sbot_whoami = []) |
8 | var sbot_links = plugs.first(exports.sbot_links = []) |
9 | |
10 | exports.avatar_image = function (author) { |
11 | var img = h('img', {src: 'http://localhost:7777/img/fallback.png'}) |
12 | sbot_whoami(function (err, me) { |
13 | if (err) return console.error(err) |
14 | getAvatar({links: sbot_links}, me.id, author, function (err, avatar) { |
15 | if (err) return console.error(err) |
16 | if(ref.isBlob(avatar.image)) |
17 | img.src = 'http://localhost:7777/'+encodeURIComponent(avatar.image) |
18 | }) |
19 | }) |
20 | return img |
21 | } |
22 | |
23 | |
24 |
Built with git-ssb-web