示例#1
0
/**
 * Initialize the plugin
 * @return void
 */
function ui_icons_init()
{
    elgg_extend_view('elements/icons.css', 'elements/avatar.css');
    elgg_register_simplecache_view('elements/avatar.sizes.css.php');
    elgg_extend_view('elements/icons.css', 'elements/avatar.sizes.css');
    elgg_set_config('icon_sizes', ui_icons_get_sizes());
    elgg_register_plugin_hook_handler('entity:icon:url', 'all', 'ui_icons_default_icon', 900);
}
<?php

$sizes = ui_icons_get_sizes();
foreach ($sizes as $name => $opts) {
    echo ".elgg-avatar-{$name} {";
    if ($opts['w']) {
        echo "max-width: {$opts['w']}px;";
    }
    if ($opts['h']) {
        echo "max-height: {$opts['h']}px;";
    }
    echo "}";
}
示例#3
0
 * @uses $vars['entity']     The entity the icon represents - uses getIconURL() method
 * @uses $vars['size']       topbar, tiny, small, medium (default), large, master
 * @uses $vars['href']       Optional override for link
 * @uses $vars['img_class']  Optional CSS class added to img
 * @uses $vars['link_class'] Optional CSS class for the link
 * @uses $vars['corners']    Corner type
 */
$entity = elgg_extract('entity', $vars);
$size = elgg_extract('size', $vars, 'small');
$icon_type = elgg_extract('icon_type', $vars, 'icon');
$width = elgg_extract('width', $vars);
$height = elgg_extract('height', $vars);
if (!$entity instanceof ElggEntity) {
    return;
}
$icon_sizes = ui_icons_get_sizes($entity);
if (!array_key_exists($size, $icon_sizes)) {
    $size = 'medium';
}
$href = $entity->getURL();
if (isset($vars['href'])) {
    $href = $vars['href'];
}
$img_class = (array) elgg_extract('img_class', $vars, array());
$img_class[] = 'elgg-avatar-image';
$title = elgg_extract('title', $vars, $entity->getDisplayName());
$img = elgg_view('output/img', array('src' => $entity->getIconURL(['size' => $size, 'type' => $icon_type]), 'alt' => $title, 'width' => $width, 'height' => $height, 'class' => $img_class));
if ($href && elgg_extract('use_link', $vars, true)) {
    $link_class = (array) elgg_extract('link_class', $vars, array());
    $link_class[] = 'elgg-tooltip';
    $img = elgg_view('output/url', array('is_trusted' => true, 'class' => $link_class, 'text' => $img, 'href' => $href, 'title' => $title));