Hi,
I would like to upload 2 differents images for my group profile but I can not see how. Can somebody help me ?
I have already read : http://learn.elgg.org/en/stable/guides/file-system.html
My code is the following to save the images (in actions directory of the plugin)
$has_uploaded_icon = (!empty($_FILES['icon']['type']) && substr_count($_FILES['icon']['type'], 'image/'));
if ($has_uploaded_icon) {
$filehandler = new ElggFile();
$filehandler->owner_guid = $group->owner_guid;
$filehandler->setFilename("groups/$group->guid.jpg");
$filehandler->open("write");
$filehandler->write(get_uploaded_file('icon'));
$filehandler->close();
if ($filehandler->exists()) {
// Non existent file throws exception
$group->saveIconFromElggFile($filehandler);
}
}
//BIG HEADER
//@see http://reference.elgg.org/filestore_8php.html#af281af99cbd2de352b8bcc0fd78b580b
$has_uploaded_icon = (!empty($_FILES['cover_photo']['type']) && substr_count($_FILES['cover_photo']['type'], 'image/'));
if ($has_uploaded_icon) {
$filehandler = new ElggFile();
$filehandler->owner_guid = $group->owner_guid;
$filehandler->setFilename("groups/$group->guid.jpg");
$filehandler->open("write");
$filehandler->write(get_uploaded_file('cover_photo'));
$filehandler->close();
if ($filehandler->exists()) {
// Non existent file throws exception
//@see $type http://reference.elgg.org/classElggEntity.html#a75c3ed83222ce4644b63b4d26e08bcfe
$group->saveIconFromElggFile($filehandler, "cover_photo");
}
}
And I retrieve an icon in the template like bellow. But I do not see how to get the "cover_photo" icon. Is it possible to have more than one icon in an entity ?
<div class="groups-profile-icon">
<?php
// we don't force icons to be square so don't set width/height
echo elgg_view_entity_icon($group, 'large', array(
'href' => '',
'width' => '',
'height' => '',
));
?>
</div>
Thanks
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.
- ihayredinov@ihayredinov

ihayredinov - 0 likes
You must log in to post replies.You are reinventing the wheel, there are already several plugins that allow you to create entity covers: https://github.com/hypejunction/hypeicons
But to answer your question, you can't display a cover image using elgg_view_entity_icon().