source: extensions/regenerateThumbnails/ws_functions.inc.php @ 29507

Last change on this file since 29507 was 9997, checked in by patdenice, 14 years ago

Minor bug corrected

File size: 1.6 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $conf;
6
7$service = &$arr[0];
8$service->addMethod(
9  'pwg.images.regenerateThumbnail',
10  'ws_images_regenerateThumbnail',
11  array(
12    'image_id'  => array(),
13    'maxwidth'  => array('default'=>$conf['upload_form_thumb_maxwidth']),
14    'maxheight' => array('default'=>$conf['upload_form_thumb_maxheight']),
15    'quality'   => array('default'=>$conf['upload_form_thumb_quality']),
16    'square'    => array('default'=>@$conf['upload_form_thumb_square']),
17  ),
18  'Regenerate a thumbnail with given arguments.'
19);
20
21function ws_images_regenerateThumbnail($params, &$service)
22{
23  global $conf;
24
25  if (!is_admin())
26    return new PwgError(401, 'Access denied');
27
28  $query='
29SELECT id, path, tn_ext
30FROM '.IMAGES_TABLE.'
31WHERE id = '.(int)$params['image_id'].'
32;';
33
34  $image = pwg_db_fetch_assoc(pwg_query($query));
35  if ($image == null)
36    return new PwgError(404, "image_id not found");
37
38  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
39
40  if ($params['square'] == 'true' or $params['square'] == 'false')
41    $params['square'] = get_boolean($params['square']);
42  if (!$params['square'])
43    remove_event_handler('upload_thumbnail_resize', 'upload_square_resize', 40);
44
45  if (!empty( $image['tn_ext'] ))
46  {
47    trigger_event(
48      'upload_thumbnail_resize',
49      false,
50      $image['path'],
51      get_thumbnail_path($image),
52      $params['maxwidth'],
53      $params['maxheight'],
54      $params['quality'],
55      true
56      );
57
58    return true;
59  }
60  return false;
61}
62
63?>
Note: See TracBrowser for help on using the repository browser.