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