/** * Get an appropriate avatar image source URL, if available. * * @param ActivityObject $actor * @param DOMElement $feed * @return string */ protected static function getAvatar(ActivityObject $actor, DOMElement $feed) { $url = ''; $icon = ''; if ($actor->avatar) { $url = trim($actor->avatar); } if (!$url) { // Check <atom:logo> and <atom:icon> on the feed $els = $feed->childNodes(); if ($els && $els->length) { for ($i = 0; $i < $els->length; $i++) { $el = $els->item($i); if ($el->namespaceURI == Activity::ATOM) { if (empty($url) && $el->localName == 'logo') { $url = trim($el->textContent); break; } if (empty($icon) && $el->localName == 'icon') { // Use as a fallback $icon = trim($el->textContent); } } } } if ($icon && !$url) { $url = $icon; } } if ($url) { $opts = array('allowed_schemes' => array('http', 'https')); if (common_valid_http_url($url)) { return $url; } } return Plugin::staticPath('OStatus', 'images/96px-Feed-icon.svg.png'); }