aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php37
1 files changed, 34 insertions, 3 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 61f655d23..8355ff760 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -2962,7 +2962,7 @@ function ws_images_resizewebsize($params, &$service)
include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
$query='
-SELECT id, path, tn_ext, has_high
+SELECT id, path, tn_ext, has_high, width, height
FROM '.IMAGES_TABLE.'
WHERE id = '.(int)$params['image_id'].'
;';
@@ -2974,12 +2974,43 @@ SELECT id, path, tn_ext, has_high
}
$image_path = $image['path'];
- $hd_path = get_high_path($image);
- if (empty($image['has_high']) or !file_exists($hd_path) or !is_valid_image_extension(get_extension($image_path)))
+ if (!is_valid_image_extension(get_extension($image_path)))
{
return new PwgError(403, "image can't be resized");
}
+
+ $hd_path = get_high_path($image);
+
+ if (empty($image['has_high']) or !file_exists($hd_path))
+ {
+ if ($image['width'] > $params['maxwidth'] or $image['height'] > $params['maxheight'])
+ {
+ $hd_path = file_path_for_type($image_path, 'high');
+ $hd_dir = dirname($hd_path);
+ prepare_directory($hd_dir);
+
+ rename($image_path, $hd_path);
+ $hd_infos = pwg_image_infos($hd_path);
+
+ single_update(
+ IMAGES_TABLE,
+ array(
+ 'has_high' => 'true',
+ 'high_filesize' => $hd_infos['filesize'],
+ 'high_width' => $hd_infos['width'],
+ 'high_height' => $hd_infos['height'],
+ ),
+ array(
+ 'id' => $image['id']
+ )
+ );
+ }
+ else
+ {
+ return new PwgError(403, "image can't be resized");
+ }
+ }
$result = false;
$img = new pwg_image($hd_path, $params['library']);