From 8be10bb100a6a4d9abc6bf7ee928d5c2e60004de Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 1 Oct 2011 19:53:37 -0400 Subject: Fixes #3912 checking that the upload succeeded before resizing --- actions/avatar/upload.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'actions/avatar') diff --git a/actions/avatar/upload.php b/actions/avatar/upload.php index 19976ea87..885a16557 100644 --- a/actions/avatar/upload.php +++ b/actions/avatar/upload.php @@ -11,6 +11,11 @@ if (!$owner || !($owner instanceof ElggUser) || !$owner->canEdit()) { forward(REFERER); } +if ($_FILES['avatar']['error'] != 0) { + register_error(elgg_echo('avatar:upload:fail')); + forward(REFERER); +} + //@todo make this configurable? $icon_sizes = array( 'topbar' => array('w'=>16, 'h'=>16, 'square'=>TRUE, 'upscale'=>TRUE), @@ -42,7 +47,7 @@ foreach ($icon_sizes as $name => $size_info) { $file->delete(); } - system_message(elgg_echo('avatar:resize:fail')); + register_error(elgg_echo('avatar:resize:fail')); forward(REFERER); } } -- cgit v1.2.3 From 5c0b61d35597677ddce30c99eccd765b8b9e1da1 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 27 Oct 2011 21:47:12 -0400 Subject: Fixes #4011 icon sizes are configurable now --- actions/avatar/crop.php | 9 +-------- engine/lib/views.php | 13 +++++++++++++ mod/groups/actions/groups/edit.php | 13 ++++++++----- 3 files changed, 22 insertions(+), 13 deletions(-) (limited to 'actions/avatar') diff --git a/actions/avatar/crop.php b/actions/avatar/crop.php index 9c57530ae..39061fa2c 100644 --- a/actions/avatar/crop.php +++ b/actions/avatar/crop.php @@ -22,14 +22,7 @@ $filehandler->owner_guid = $owner->getGUID(); $filehandler->setFilename("profile/" . $owner->guid . "master" . ".jpg"); $filename = $filehandler->getFilenameOnFilestore(); -//@todo make this configurable? -$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) -); +$icon_sizes = elgg_get_config('icon_sizes'); // get the images and save their file handlers into an array // so we can do clean up if one fails. diff --git a/engine/lib/views.php b/engine/lib/views.php index 070b59e37..e8cb20232 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1617,6 +1617,19 @@ function elgg_views_boot() { elgg_register_viewtype($view); } } + + // set default icon sizes - can be overridden in settings.php or with plugin + if (!elgg_get_config('icon_sizes')) { + $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), + ); + elgg_set_config('icon_sizes', $icon_sizes); + } } elgg_register_event_handler('boot', 'system', 'elgg_views_boot', 1000); diff --git a/mod/groups/actions/groups/edit.php b/mod/groups/actions/groups/edit.php index 3a0376497..27f6e0426 100644 --- a/mod/groups/actions/groups/edit.php +++ b/mod/groups/actions/groups/edit.php @@ -111,7 +111,10 @@ if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') { // Now see if we have a file icon if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/'))) { - $prefix = "groups/".$group->guid; + + $icon_sizes = elgg_get_config('icon_sizes'); + + $prefix = "groups/" . $group->guid; $filehandler = new ElggFile(); $filehandler->owner_guid = $group->owner_guid; @@ -120,10 +123,10 @@ if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/')) $filehandler->write(get_uploaded_file('icon')); $filehandler->close(); - $thumbtiny = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),25,25, true); - $thumbsmall = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),40,40, true); - $thumbmedium = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),100,100, true); - $thumblarge = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),200,200, false); + $thumbtiny = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $icon_sizes['tiny']['w'], $icon_sizes['tiny']['h'], $icon_sizes['tiny']['square']); + $thumbsmall = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $icon_sizes['small']['w'], $icon_sizes['small']['h'], $icon_sizes['small']['square']); + $thumbmedium = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $icon_sizes['medium']['w'], $icon_sizes['medium']['h'], $icon_sizes['medium']['square']); + $thumblarge = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $icon_sizes['large']['w'], $icon_sizes['large']['h'], $icon_sizes['large']['square']); if ($thumbtiny) { $thumb = new ElggFile(); -- cgit v1.2.3 From 9afd9bfd044743d5907464b79c5904ced06cf21b Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 5 Nov 2011 07:56:12 -0400 Subject: Refs #4011 forgot upload action --- actions/avatar/upload.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'actions/avatar') diff --git a/actions/avatar/upload.php b/actions/avatar/upload.php index 885a16557..2e8ff98b3 100644 --- a/actions/avatar/upload.php +++ b/actions/avatar/upload.php @@ -16,15 +16,7 @@ if ($_FILES['avatar']['error'] != 0) { forward(REFERER); } -//@todo make this configurable? -$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'=>TRUE), - 'master' => array('w'=>550, 'h'=>550, 'square'=>FALSE, 'upscale'=>FALSE) -); +$icon_sizes = elgg_get_config('icon_sizes'); // get the images and save their file handlers into an array // so we can do clean up if one fails. -- cgit v1.2.3 From 87a7d965c87e882857fc759d765a9d6b2f01fafa Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 15 Nov 2011 20:30:59 -0500 Subject: fixed bugs in avatar cropping with remembering old crop coordinates and resizing the master --- actions/avatar/crop.php | 1 + actions/avatar/upload.php | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'actions/avatar') diff --git a/actions/avatar/crop.php b/actions/avatar/crop.php index 39061fa2c..6d71b6f06 100644 --- a/actions/avatar/crop.php +++ b/actions/avatar/crop.php @@ -23,6 +23,7 @@ $filehandler->setFilename("profile/" . $owner->guid . "master" . ".jpg"); $filename = $filehandler->getFilenameOnFilestore(); $icon_sizes = elgg_get_config('icon_sizes'); +unset($icon_sizes['master']); // get the images and save their file handlers into an array // so we can do clean up if one fails. diff --git a/actions/avatar/upload.php b/actions/avatar/upload.php index 2e8ff98b3..0752615e0 100644 --- a/actions/avatar/upload.php +++ b/actions/avatar/upload.php @@ -44,6 +44,12 @@ foreach ($icon_sizes as $name => $size_info) { } } +// reset crop coordinates +$owner->x1 = 0; +$owner->x2 = 0; +$owner->y1 = 0; +$owner->y2 = 0; + $owner->icontime = time(); if (elgg_trigger_event('profileiconupdate', $owner->type, $owner)) { system_message(elgg_echo("avatar:upload:success")); -- cgit v1.2.3