is their a way to save the user icon as the same width of the image? I'm using the following code to upload the image and save it but on the user profile it crops the photo... I dont want it to crop, want it to display the whole image
$icon_sizes = elgg_get_config('icon_sizes');
$filehandler = new ElggFile();
$filehandler->owner_guid = $new_user->guid;
foreach ($icon_sizes as $size => $dimensions) {
//$image = get_resized_image_from_existing_file(
// $photoreference, $dimensions[0], $dimensions[1], $dimensions[2]
// );
//$image = get_resized_image_from_existing_file($photoreference, $dimensions['w'], $dimensions['h'], $dimensions['square'], 0, 0, 0, 0, $dimensions['upscale']);
$filehandler->setFilename("profile/{$new_user->guid}{$size}.jpg");
$filehandler->open('write');
$filehandler->write(file_get_contents($photoreference));
$filehandler->close();
}
$new_user->icontime = time();
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.
- adrew22a@drew22a

adrew22a - 0 likes
- iionly@iionly

iionly - 0 likes
You must log in to post replies.I started doing this instead but it says Avatar resizing failed. Im trying to grab a image from a URL.
$icon_sizes = array(
'topbar' => array('w' => 16, 'h' => 16, 'square' => TRUE, 'upscale' => TRUE),
'tiny' => array('w' => 25, 'h' => 25, 'square' => TRUE, 'upscale' => TRUE),
'small' => array('w' => 40, 'h' => 40, 'square' => TRUE, 'upscale' => TRUE),
'medium' => array('w' => 100, 'h' => 100, 'square' => TRUE, 'upscale' => TRUE),
'large' => array('w' => 200, 'h' => 200, 'square' => FALSE, 'upscale' => FALSE),
'master' => array('w' => 550, 'h' => 550, 'square' => FALSE, 'upscale' => FALSE),
);
// get the images and save their file handlers into an array
// so we can do clean up if one fails.
$files = array();
foreach ($icon_sizes as $name => $size_info) {
echo $resized = get_resized_image_from_uploaded_file($photoreference, $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']);
if ($resized) {
$file = new ElggFile();
$file->owner_guid = $new_user->guid;
$file->setFilename("profile/{$new_user->guid}{$name}.jpg");
$file->open('write');
$file->write($resized);
$file->close();
$files[] = $file;
} else {
// cleanup on fail
foreach ($files as $file) {
$file->delete();
}
register_error(elgg_echo('avatar:resize:fail'));
//forward(REFERER);
}
}
$new_user->icontime = time();
The original unresize profile image is also already saved ("<image-filename>master"). I think the view mod/profile/views/default/profile/owner_block.php deals with displaying the profile image on the profile page:
$icon = elgg_view_entity_icon($user, 'large', array(
'use_hover' => false,
'use_link' => false,
));
If you would change "large" to "master" the unresized image should show up. But this will very likely result in layout issues because the column the profile image is displayed in does have a fixed size. And displaying the profile image in original size regarless how large it is will surely be a serious issue. Even if you limit the width of the column to a certain max width you will still have to modify the profile page layout to deal with the possible very large profile image.