How to remove elgg icon in elgg 2.01?

I am using elgg 2.01 and want to remove elgg icon.I tried a lot and finally found the location which is...vendor/elgg/elgg/engine/lib/views
What I did actually,
I changed favicon.ico to favicon.png from views(php) and uploaded my images to _graphics folder(i.e I changed the core files which I should not do).
So,Please tell me how can I override that file to have my own icon.
Thanks in advance!!!

  • I think it should work like this: create the directories views/default/ into the site root directory (not in vendor/elgg/elgg/) and add favicon.ico there.

    By default you can also add:

    • favicon-16.png (16x16 pixels)
    • favicon-32.png
    • favicon-64.png
    • favicon-128.png

    Different devices may use different size of the icons.

  • Take the full complete hook:

    elgg_register_plugin_hook_handler('head', 'page', 'theme_setup_head');
    
    function theme_setup_head($hook, $type, $return, $params) {
    
       $return['metas'] = false;
        
        $return['metas'][] = array(
            'name' => 'viewport',
            'content' => 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0',
        );
    
        $return['metas'][] = array(
            'name' => 'mobile-web-app-capable',
            'content' => 'yes',
        );
    
        $return['metas'][] = array(
            'name' => 'apple-mobile-web-app-capable',
            'content' => 'yes',
        );
    
        $return['metas'][] = array(
            'name' => 'msapplication-TileColor',
            'content' => '#2b5797',
        );
        
        $return['metas'][] = array(
            'name' => 'msapplication-TileImage',
            'content' => elgg_normalize_url('mod/theme/i/mstile-144x144.png'),
        );
        
        $return['metas'][] = array(
            'name' => 'msapplication-config',
            'content' => elgg_normalize_url('/browserconfig.xml'),
        );
        
        $return['links'] = false;
        
        $return['links'][] = array(
            'rel' => 'icon',
            'type' => 'image/x-icon',
            'href' => elgg_normalize_url('/favicon.ico'),
        );
        
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '16x16',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-16.png'),
        );
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '32x32',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-32.png'),
        );
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '64x64',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-64.png'),
        );
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '96x96',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-96.png'),
        );
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '128x128',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-128.png'),
        );
        
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '180x180',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-180x180.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '152x152',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-152x152.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '144x144',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-144x144.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '120x120',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-120x120.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '114x114',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-114x114.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '76x76',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-76x76.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '72x72',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-72x72.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '60x60',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-60x60.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '57x57',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-57x57.png'),
        );
        
        $return['links']['manifest'] = array(
            'rel' => 'manifest',
            'href' => elgg_normalize_url('/manifest.json'),
        );
    
        return $return;
    }
  • @RvR,Where to place this code I mean in which ditectory,should i create a new plugin or what_?

  • @Juho,I did it but that elgg icon is still there

  • The way I described works for me. It may be that the old icon is still stored in your browser's cache.

  • I cleared my history and cache,but no effect,its still there..should I change core files?

  • @Rvr I created a new plugin and placed that code in start.php and it is showing blank page.Please helppppp.......

  • @Shubham Jaiswal

    Here's a full start.php of your plugin named theme:

    <?php
    
    elgg_register_event_handler('init','system','theme_init');
    
    function theme_init() {
     elgg_register_plugin_hook_handler('head', 'page', 'theme_setup_head');
    }
    
    function theme_setup_head($hook, $type, $return, $params) {
    
        $return['metas'] = false;
        
        $return['metas'][] = array(
            'name' => 'viewport',
            'content' => 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0',
        );
    
        $return['metas'][] = array(
            'name' => 'mobile-web-app-capable',
            'content' => 'yes',
        );
    
        $return['metas'][] = array(
            'name' => 'apple-mobile-web-app-capable',
            'content' => 'yes',
        );
    
        $return['metas'][] = array(
            'name' => 'msapplication-TileColor',
            'content' => '#2b5797',
        );
        
        $return['metas'][] = array(
            'name' => 'msapplication-TileImage',
            'content' => elgg_normalize_url('mod/theme/i/mstile-144x144.png'),
        );
        
        $return['metas'][] = array(
            'name' => 'msapplication-config',
            'content' => elgg_normalize_url('/browserconfig.xml'),
        );
        
        $return['links'] = false;
        
        $return['links'][] = array(
            'rel' => 'icon',
            'type' => 'image/x-icon',
            'href' => elgg_normalize_url('/favicon.ico'),
        );
        
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '16x16',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-16.png'),
        );
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '32x32',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-32.png'),
        );
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '64x64',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-64.png'),
        );
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '96x96',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-96.png'),
        );
        $return['links'][] = array(
            'rel' => 'icon',
            'sizes' => '128x128',
            'type' => 'image/png',
            'href' => elgg_normalize_url('mod/theme/i/favicon-128.png'),
        );
        
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '180x180',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-180x180.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '152x152',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-152x152.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '144x144',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-144x144.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '120x120',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-120x120.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '114x114',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-114x114.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '76x76',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-76x76.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '72x72',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-72x72.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '60x60',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-60x60.png'),
        );
        $return['links'][] = array(
            'rel' => 'apple-touch-icon',
            'sizes' => '57x57',
            'href' => elgg_normalize_url('mod/theme/i/apple-touch-icon-57x57.png'),
        );
        
        $return['links']['manifest'] = array(
            'rel' => 'manifest',
            'href' => elgg_normalize_url('/manifest.json'),
        );
    
        return $return;
    }

    Replace your icons to /mod/theme/i/ folder, or change it in the above code

  • @Juho: your suggestion doesn't work for me. Are you sure that it works on a default (zip based) installation of Elgg 2.X?

    Favicon override plugin: https://elgg.org/plugins/2446383.

  • Yes, I tested now, it and it works. Starting from Elgg 2 favicons are stored under views/ so they can be overridden like any other view simply by dropping in the replacement. There is no need to add any code.

    I believe the problem is that browsers cache the favicon very persistently. Even clearing the browser caches isn't always enough, but it may require additional tricks to make the new one visible.