Make a folder "default_icons" directly inside your plugin's folder and add PNG images prefixed with either "user-" or "group-". Example:
myPlugin
/default_icons
/group-defaultsmall.png
/user-defaultsmall.png
Icon URLs are set by the "entity:icon:url" plugin hook, so we add a handler to look for and replace the default paths. (Since you may not have a full set of replacements, the handler below first checks that your replacement PNG exists.)
elgg_register_plugin_hook_handler('entity:icon:url', 'all', 'myPlugin_alter_default_icons', 999);
function myPlugin_alter_default_icons($hook, $type, $returnValue, $params) {
$file = '';
if (0 === strpos($returnValue, 'mod/groups/graphics/default')) {
$file = __DIR__ . '/default_icons/group-' . substr($returnValue, 20);
} elseif (0 === strpos($returnValue, '_graphics/icons/user/default')) {
$file = __DIR__ . '/default_icons/user-' . substr($returnValue, 21);
}
if ($file) {
$file = str_replace('.gif', '.png', $file); // our designer wants PNG files
}
if (file_exists($file)) {
$returnValue = "mod/" . basename(__DIR__) . substr($file, strlen(__DIR__));
}
return $returnValue;
}
If you want to stick with GIF images, just remove the line with str_replace().
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.
does this hook need to triggered too? if yes, then where should i trigger this hook?
I tried putting this code in start.php, and created directories as you mentioned, but it still displays the icon in _graphics/icons/default/*.
entity:icon:url is triggerred by Elgg. Use something like xdebug to make sure your handler function is being called.