From 8e8e50d510608d94e266e3c951349a45046dfc67 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 5 Jun 2009 11:26:42 +0000 Subject: added image sizes to settings and removed deprecated settings object --- lib/resize.php | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/resize.php b/lib/resize.php index f9b7843e5..186900f7d 100644 --- a/lib/resize.php +++ b/lib/resize.php @@ -19,10 +19,17 @@ $mime = $file->getMimeType(); + $image_sizes = get_plugin_setting('image_sizes', 'tidypics'); + if (!$image_sizes) { + register_error(elgg_echo('tidypics:nosettings')); + return false; + } + $image_sizes = unserialize($image_sizes); + // Generate thumbnails $thumbnail = get_resized_image_from_existing_file( $file->getFilenameOnFilestore(), - $CONFIG->tidypics->image_thumb_width, - $CONFIG->tidypics->image_thumb_height, + $image_sizes['thumb_image_width'], + $image_sizes['thumb_image_height'], true); if ($thumbnail) { @@ -41,8 +48,8 @@ unset($thumbnail); $thumbsmall = get_resized_image_from_existing_file( $file->getFilenameOnFilestore(), - $CONFIG->tidypics->image_small_width, - $CONFIG->tidypics->image_small_height, + $image_sizes['small_image_width'], + $image_sizes['small_image_height'], true); @@ -62,8 +69,8 @@ unset($thumbsmall); $thumblarge = get_resized_image_from_existing_file( $file->getFilenameOnFilestore(), - $CONFIG->tidypics->image_large_width, - $CONFIG->tidypics->image_large_height, + $image_sizes['large_image_width'], + $image_sizes['large_image_height'], false); if ($thumblarge) { @@ -116,22 +123,29 @@ $mime = $file->getMimeType(); + $image_sizes = get_plugin_setting('image_sizes', 'tidypics'); + if (!$image_sizes) { + register_error(elgg_echo('tidypics:nosettings')); + return array(); + } + $image_sizes = unserialize($image_sizes); + $thumblarge = tp_imagick_resize($file->getFilenameOnFilestore(), "largethumb", - $CONFIG->tidypics->image_large_width, - $CONFIG->tidypics->image_large_height, + $image_sizes['large_image_width'], + $image_sizes['large_image_height'], false); $thumbsmall = tp_imagick_resize($file->getFilenameOnFilestore(), "smallthumb", - $CONFIG->tidypics->image_small_width, - $CONFIG->tidypics->image_small_height, + $image_sizes['small_image_width'], + $image_sizes['small_image_height'], true); $thumbnail = tp_imagick_resize($file->getFilenameOnFilestore(), "thumb", - $CONFIG->tidypics->image_thumb_width, - $CONFIG->tidypics->image_thumb_height, + $image_sizes['thumb_image_width'], + $image_sizes['thumb_image_height'], true); if ($thumbnail) { -- cgit v1.2.3