Changeset 10235
- Timestamp:
- Apr 10, 2011, 10:59:02 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r10160 r10235 2659 2659 } 2660 2660 } 2661 2662 function ws_images_resize($params, &$service) 2663 { 2664 global $conf; 2665 2666 if (!is_admin()) 2667 { 2668 return new PwgError(401, 'Access denied'); 2669 } 2670 2671 if (!in_array($params['type'], array('thumbnail', 'websize'))) 2672 { 2673 return new PwgError(403, 'Unknown type (only "thumbnail" or "websize" are accepted'); 2674 } 2675 2676 $resize_params = array('maxwidth', 'maxheight', 'quality'); 2677 $type = $params['type'] == 'thumbnail' ? 'thumb' : 'websize'; 2678 foreach ($resize_params as $param) 2679 { 2680 if (empty($params[$param])) 2681 $params[$param] = $conf['upload_form_'.$type.'_'.$param]; 2682 } 2683 2684 $query=' 2685 SELECT id, path, tn_ext, has_high 2686 FROM '.IMAGES_TABLE.' 2687 WHERE id = '.(int)$params['image_id'].' 2688 ;'; 2689 $image = pwg_db_fetch_assoc(pwg_query($query)); 2690 2691 if ($image == null) 2692 { 2693 return new PwgError(403, "image_id not found"); 2694 } 2695 2696 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 2697 2698 if (!is_valid_image_extension(get_extension($image['path']))) 2699 { 2700 return new PwgError(403, "image can't be resized"); 2701 } 2702 2703 if ($params['type'] == 'thumbnail' and !empty($image['tn_ext'])) 2704 { 2705 trigger_event( 2706 'upload_thumbnail_resize', 2707 false, 2708 $image['path'], 2709 get_thumbnail_path($image), 2710 $params['maxwidth'], 2711 $params['maxheight'], 2712 $params['quality'], 2713 true 2714 ); 2715 return true; 2716 } 2717 elseif (!empty($image['has_high'])) 2718 { 2719 trigger_event( 2720 'upload_image_resize', 2721 false, 2722 file_path_for_type($image['path'], 'high'), 2723 $image['path'], 2724 $params['maxwidth'], 2725 $params['maxheight'], 2726 $params['quality'], 2727 false 2728 ); 2729 return true; 2730 } 2731 return false; 2732 } 2661 2733 ?> -
trunk/ws.php
r10017 r10235 404 404 'activate/deactivate/delete/set_default a theme<br>administration status required' 405 405 ); 406 407 $service->addMethod( 408 'pwg.images.resize', 409 'ws_images_resize', 410 array( 411 'image_id' => array(), 412 'type' => array('default' => 'thumbnail'), 413 'maxwidth' => array('default' => null), 414 'maxheight' => array('default' => null), 415 'quality' => array('default' => null), 416 ), 417 'Regenerate thumbnails or websize photo with given arguments. 418 <br>Argument "type" can be "thumbnail" or "websize". Default is "thumbnail". 419 <br>If maxwidth, maxheight or quality are missing, default parameters of upload will be used.' 420 ); 406 421 } 407 422
Note: See TracChangeset
for help on using the changeset viewer.