Changeset 10235 for trunk/include/ws_functions.inc.php
- Timestamp:
- Apr 10, 2011, 10:59:02 AM (13 years ago)
- File:
-
- 1 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 ?>
Note: See TracChangeset
for help on using the changeset viewer.