2020-05-28 13:57:02 +03:00
|
|
|
const urlUtils = require('../../shared/url-utils');
|
2021-07-01 14:30:23 +03:00
|
|
|
const getContextObject = require('./context-object.js');
|
2020-04-29 18:44:27 +03:00
|
|
|
const _ = require('lodash');
|
2016-01-17 13:07:52 +03:00
|
|
|
|
|
|
|
function getAuthorImage(data, absolute) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const context = data.context ? data.context : null;
|
|
|
|
const contextObject = getContextObject(data, context);
|
2016-01-17 13:07:52 +03:00
|
|
|
|
2018-03-27 17:16:15 +03:00
|
|
|
if ((_.includes(context, 'post') || _.includes(context, 'page')) && contextObject.primary_author && contextObject.primary_author.profile_image) {
|
2019-06-18 16:13:55 +03:00
|
|
|
return urlUtils.urlFor('image', {image: contextObject.primary_author.profile_image}, absolute);
|
2016-01-17 13:07:52 +03:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = getAuthorImage;
|