Elgg Release - 2.3.10, Version - 2016092300 displays uses Square shape avatar while the Elgg 3.0.0-rc.2 displays Round Shape Avatar.
If I replace the Elgg 2.3.10 icon script with Elgg 3.0.0-rc.2 shouldn't it work?
2.3.10 script is as following:
<?php
/**
* Generic icon view.
*
* @package Elgg
* @subpackage Core
*
* @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
*/
$entity = $vars['entity'];
/* @var ElggEntity $entity */
$icon_sizes = elgg_get_icon_sizes($entity->type, $entity->getSubtype());
// Get size
$size = elgg_extract('size', $vars, 'medium');
if (!array_key_exists($size, $icon_sizes)) {
$size = "medium";
}
$vars['size'] = $size;
$class = elgg_extract('img_class', $vars, '');
if (isset($entity->name)) {
$title = $entity->name;
} else {
$title = $entity->title;
}
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false);
$url = $entity->getURL();
if (isset($vars['href'])) {
$url = $vars['href'];
}
if (!isset($vars['width'])) {
$vars['width'] = $size != 'master' ? $icon_sizes[$size]['w'] : null;
}
if (!isset($vars['height'])) {
$vars['height'] = $size != 'master' ? $icon_sizes[$size]['h'] : null;
}
$img_params = array(
'src' => $entity->getIconURL($size),
'alt' => $title,
);
if (!empty($class)) {
$img_params['class'] = $class;
}
if (!empty($vars['width'])) {
$img_params['width'] = $vars['width'];
}
if (!empty($vars['height'])) {
$img_params['height'] = $vars['height'];
}
$img = elgg_view('output/img', $img_params);
if ($url) {
$params = array(
'href' => $url,
'text' => $img,
'is_trusted' => true,
);
$class = elgg_extract('link_class', $vars, '');
if ($class) {
$params['class'] = $class;
}
echo elgg_view('output/url', $params);
} else {
echo $img;
}
would like to replace it with
<?php
/**
* Elgg user icon
*
* Rounded avatar corners - CSS3 method
* uses avatar as background image so we can clip it with border-radius in supported browsers
*
* @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
* @uses $vars['size'] The size - tiny, small, medium or large. (medium)
* @uses $vars['use_hover'] Display the hover menu? (true)
* @uses $vars['use_link'] Wrap a link around image? (true)
* @uses $vars['class'] Optional class added to the .elgg-avatar div
* @uses $vars['img_class'] Optional CSS class added to img
* @uses $vars['link_class'] Optional CSS class for the link
* @uses $vars['href'] Optional override of the link href
*/
$user = elgg_extract('entity', $vars, elgg_get_logged_in_user_entity());
$size = elgg_extract('size', $vars, 'medium');
if (!($user instanceof ElggUser)) {
return;
}
$icon_sizes = elgg_get_icon_sizes('user');
if (!array_key_exists($size, $icon_sizes)) {
$size = 'medium';
}
$name = htmlspecialchars($user->getDisplayName(), ENT_QUOTES, 'UTF-8', false);
$username = $user->username;
$wrapper_class = [
'elgg-avatar',
"elgg-avatar-$size",
];
$wrapper_class = elgg_extract_class($vars, $wrapper_class);
if ($user->isBanned()) {
$wrapper_class[] = 'elgg-state-banned';
$name .= ' (' . elgg_echo('banned') . ')';
}
$icon = elgg_view('output/img', [
'src' => $user->getIconURL($size),
'alt' => $name,
'title' => $name,
'class' => elgg_extract_class($vars, [], 'img_class'),
]);
if (empty($icon)) {
return;
}
$show_menu = elgg_extract('use_hover', $vars, true) && (elgg_is_admin_logged_in() || !$user->isBanned());
$content = '';
if ($show_menu) {
$params = [
'entity' => $user,
'username' => $username,
'name' => $name,
];
$content .= elgg_view('navigation/menu/user_hover/placeholder', ['entity' => $user]);
$wrapper_class[] = 'elgg-avatar-menu';
}
if (elgg_extract('use_link', $vars, true)) {
$content .= elgg_view('output/url', [
'href' => elgg_extract('href', $vars, $user->getURL()),
'text' => $icon,
'is_trusted' => true,
'class' => elgg_extract_class($vars, [], 'link_class'),
]);
} else {
$content .= elgg_format_element('a', [], $icon);
}
echo elgg_format_element('div', ['class' => $wrapper_class], $content);
Is there more to it?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- MyHoTFB.COM ®@myHoTFB
MyHoTFB.COM ® - 0 likes
You must log in to post replies.Don't touch anything from Elgg 3.x Especially if you don't know what you're doing.
Use CSS instead.
Ok Sir. Understood.