Full wide groups icon

Hi community!

To enhance groups displaying, I´ve modified the groups CSS to show the group icon at the top of the page, and I´ve tweaked the file summary.php to full wide fit:

 echo elgg_view_entity_icon($group, 'large', array(
                                        'href' => '',
                                        'width' => '100%',
                                        'height' => '',
                                ));

The problem is about the icon image resolution, I see the groups icon doesn't generates the 'master' image size, and this is the size I need, so my question is:

How can I generate the 'master' size to use it in the code?:

 echo elgg_view_entity_icon($group, 'master', array(
                                        'href' => '',
                                        'width' => '100%',
                                        'height' => '',
                                ));

...or use the original uploaded image.

This is a capture of my idea

Thanks

 

  • By default ;s:

    elgg_view_entity_icon($group, 'master');

    For customising it you need to override   elgg_view("icon/default");  in

    views\default\icon\default.php

    Documentation

  • @RvR I don't understand what should I do.

    I've looked in the file default.php but I dont know what code I must tweak.

    And in the Documentation the 'master' size don't appears

    Can you explain me a bit more?

    Thanks.

  • An issue about missing group master icon has already been opened and a fix is currently in the making: https://github.com/Elgg/Elgg/pull/7265.

  • Ok @iionly, I´ll wait for the fix. 

    Until it is solved, can I tweak this code in summary.php:

     echo elgg_view_entity_icon($group, 'large', array(
                                            'href' => '',
                                            'width' => '100%',
                                            'height' => '',
                                    ));

    ...to use the original uploaded image as group icon?

    Thanks.

  • Similar discussion recently: https://community.elgg.org/discussion/view/1873432/check-datafolder-for-icon-size.

    You can use the same approach but instead of serving a custom size image you can serve the original image instead of the 'large' image:

    <?php

    elgg_register_event_handler('init', 'system', 'customsize_groupimage_init');

    function customsize_groupimage_init() {
        elgg_register_plugin_hook_handler('entity:icon:url', 'group', 'customsize_groupimage_hook', 900);
    }

    function customsize_groupimage_hook($hook, $entity_type, $returnvalue, $params) {

        if (($hook != 'entity:icon:url') || ($hook == 'entity:icon:url') && ($params['size'] != 'large')) {
            return;
        }

        if ($params['entity'] instanceof ElggGroup) {
            $entity = $params['entity'];
            $filehandler = new ElggFile();
            $filehandler->owner_guid = $entity->owner_guid;
            $filehandler->setFilename("groups/" . $entity->guid .  ".jpg");

            if (!$filehandler->exists()) {
                $entity_guid = $entity->guid;
                $entity_icontime = $entity->icontime;
                $return = "groupicon/{$entity_guid}/large/{$entity_icontime}.jpg";
                return $return;
            } else {
                return $returnvalue;
            }
        } else {
            return $returnvalue;
        }
    }

  • I´ve copied the code into start.php of groups plugin, but it don't works (I´ve a own plugin to customize groups, I also tested the code in start.php of this plugin).

    In summary.php I´ve this code:

    echo elgg_view_entity_icon($group, 'master', array(
                                            'href' => '',
                                            'width' => '100%',
                                            'height' => '',
                                    ));

    and in your suggested code I´ve:

     if (($hook != 'entity:icon:url') || ($hook == 'entity:icon:url') && ($params['size'] != 'master')) {
            return;
        }

    Is this the right way to apply the patch?

    Thanks.

  • The group icon uploaded through elgg Icon upload form is not rectangle icon. Most of the elgg icons are cropped during group icon upload time. So if you take the group master icon and use it as 100 %, the image might not be shown properly even after the group icon bug fix.

    Remember, most online users nowdays browse social network via phone devices.

    For more information read this discussion.

    1. New Elgg Cover Photo Plugin

    https://community.elgg.org/discussion/view/1856576/new-elgg-cover-photo-plugin

  • Hi @Tom, your Elgg Cover Photo Album is just I need for my net. Your post is very useful.

    I´m looking for the best engagement throught better groups profile displaying, with bigger images in widgets and full wide cover profile icon.

    My net is also responsive, so I must be more carefully with this point.

    About the group icon, I see in blogs that is 'master' the size used, and is valid for rectangular full wide displaying (because I upload a rectangular image). Example

    For groups I´ll do the same (I spend time looking for and designing the best image icon, as you say in your post). This is I need: Example group profile. In this case, I´m using the original uploaded image (I´ve copied ORIGINAL.jpg to ORIGINALmaster.jpg manually)

    So until your plugin be ready, or the master icon issue is solved, I need to use the original uploaded image in groups, and the @iionly's code may help me, but I don't know how to apply it.

    Thanks @Tom. 

     

     

     

     

  • Forget about the code I've posted above. It won't work with this code alone. Using the 'entity:icon:url', 'group' plugin hook you can only change the URL where Elgg has to look for the image but it's not possible to make it use the original image as fallback for master.

    Check out this: https://github.com/iionly/Elgg_1.8_customsize_groupimage

    It's a little plugin I've written that should do the trick. The "large" group icon is replaced the "master" group icon and instead of the "master" size the original image is used respectively. You might not need to make any other changes if you are okay with the large-sized group image being replaced everywhere (though as far as I know it's only used on group profile pages by default so it shouldn't make a difference). If you want to explicitely define where the master-sized image is to be used, then comment out the registering of the plugin handler that replaces "large" with "master".

    You might still have to make some adjustments in the CSS files (which you might want to add to this plugin then) to make it look right on your site (with your theme).

  • Thank you so much @iionly, it works perfect!!, and my net looks much better now!!!

    Thanks again!!!!

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