Replace default "groups" and "user" avatar icons

Hey everybody.

I am looking to replace the default "groups" and "user" icon through a plugin, but it looks like the icons are handled a special way (especially for group). I found this old page:

https://elgg.org/pages/view/839193/how-to-change-elggs-default-usergroup-profile-icons

but I feel like it would no longer apply to the newest version of elgg.

Thanks,

- Ben

(P.S: I used to be a member of the community a few years ago & I made quite a few plugins. Excited to be developing with elgg and looking forward to sharing some new plugins with the community.)

  • in the root of plugin you  will see graphics folder, in this folder you have default icon of groups. delete it and put your own on the same name 

  • Don't delete anything.
    Icons are in the view system these days, so you should be able to replace them in a plugin just like any other view. Enable the developers plugin and you will see how file locations map to view names in View inspector

  • Hi Ismayil. Thanks for the response :) 

    I actually checked the view inspector and I found these file locations:

    groups/defaultlarge.gif 500 mod/groups/graphics/defaultlarge.gif
    groups/defaultmedium.gif 500 mod/groups/graphics/defaultmedium.gif
    groups/defaultsmall.gif 500 mod/groups/graphics/defaultsmall.gif
    groups/defaulttiny.gif 500

    mod/groups/graphics/defaulttiny.gif

    I'm still a little thrown off because they aren't in the views/ folder of the groups plugin so I don't know how I would go about overriding it in a different plugin. It has to do with the elgg-plugin.php right?

  • It has to do with the elgg-plugin.php right?

    Nope.

    Override these:

    elgg_register_plugin_hook_handler('entity:icon:url', 'user', 'user_avatar_hook'); //Users' icons
    
    elgg_register_plugin_hook_handler('entity:icon:url', 'group', 'groups_set_icon_url'); //Groups' icons

    in start.php of your own plugin.

    Learn more on http://learn.elgg.org/en/stable/guides/hooks-list.html#other - - entity:icon:url section

  • Awesome! Got it working. Thank you for your help! 

     

    Looking forward to being back in the elgg community. 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking