Elgg\EntityIconService::getIconURL PHP Method

getIconURL() public method

Plugins can register for the 'entity:icon:url', plugin hook to customize the icon for an entity.
public getIconURL ( ElggEntity $entity, mixed $params = [] ) : string | void
$entity ElggEntity Entity that owns the icon
$params mixed A string defining the size of the icon (e.g. tiny, small, medium, large) or an array of parameters including 'size'
return string | void
    public function getIconURL(ElggEntity $entity, $params = array())
    {
        if (is_array($params)) {
            $size = elgg_extract('size', $params, 'medium');
        } else {
            $size = is_string($params) ? $params : 'medium';
            $params = array();
        }
        $size = elgg_strtolower($size);
        $params['entity'] = $entity;
        $params['size'] = $size;
        $type = elgg_extract('type', $params) ?: 'icon';
        $entity_type = $entity->getType();
        $url = $this->hooks->trigger("entity:{$type}:url", $entity_type, $params, null);
        if ($url == null) {
            if ($this->hasIcon($entity, $size, $type)) {
                $icon = $this->getIcon($entity, $size, $type);
                $url = elgg_get_inline_url($icon, true);
            } else {
                $url = $this->getFallbackIconUrl($entity, $params);
            }
        }
        if ($url) {
            return elgg_normalize_url($url);
        }
    }