/**
 * User avatar icon URL handler
 *
 * @param string $hook   "entity:icon:url"
 * @param string $type   "object"
 * @param string $return URL
 * @param array  $params Hook params
 * @return array
 */
function avatars_user_icon_url($hook, $type, $return, $params)
{
    $entity = elgg_extract('entity', $params);
    $size = elgg_extract('size', $params);
    $avatar = avatars_get_avatar($entity);
    if (!$avatar) {
        return;
    }
    $thumb = images()->getThumb($avatar, $size);
    if (!$thumb) {
        return;
    }
    return elgg_get_inline_url($thumb, false);
}
<?php

$entity = elgg_extract('entity', $vars);
$avatar = avatars_get_avatar($entity);
$form = elgg_view_form('avatars/upload', ['enctype' => 'multipart/form-data'], ['entity' => $avatar, 'container_guid' => $entity->guid]);
echo elgg_view_module('info', elgg_echo('avatar:upload'), $form);
Exemple #3
0
/**
 * Replace entity icon URL if entity has an avatar
 *
 * @param string $hook   "entity:icon:url"
 * @param string $type   "all"
 * @param string $return Icon URL
 * @param array  $params Hook params
 * @return array
 */
function avatars_entity_icon_url_handler($hook, $type, $return, $params)
{
    $entity = elgg_extract('entity', $params);
    $size = elgg_extract('size', $params);
    if (!avatars_enabled($entity->getType(), $entity->getSubtype())) {
        return;
    }
    $avatar = avatars_get_avatar($entity);
    if ($avatar) {
        return $avatar->getIconURL($size);
    }
}