Changeset 10563 for trunk/include/ws_functions.inc.php
- Timestamp:
- Apr 22, 2011, 1:34:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r10553 r10563 2674 2674 } 2675 2675 2676 if (empty($params['image_id']) and empty($params['image_path'])) 2677 { 2678 return new PwgError(403, "image_id or image_path is missing"); 2679 } 2680 2676 2681 $resize_params = array('maxwidth', 'maxheight', 'quality', 'crop', 'follow_orientation'); 2677 2682 $type = $params['type'] == 'thumbnail' ? 'thumb' : 'websize'; … … 2682 2687 } 2683 2688 2684 $query=' 2689 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); 2690 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 2691 2692 if (!empty($params['image_id'])) 2693 { 2694 $query=' 2685 2695 SELECT id, path, tn_ext, has_high 2686 FROM '.IMAGES_TABLE.'2687 WHERE id = '.(int)$params['image_id'].'2696 FROM '.IMAGES_TABLE.' 2697 WHERE id = '.(int)$params['image_id'].' 2688 2698 ;'; 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 $image = pwg_db_fetch_assoc(pwg_query($query)); 2700 2701 if ($image == null) 2702 { 2703 return new PwgError(403, "image_id not found"); 2704 } 2705 2706 $image_path = $image['path']; 2707 $thumb_path = get_thumbnail_path($image); 2708 $hd_path = get_high_path($image); 2709 } 2710 else 2711 { 2712 $image_path = $params['image_path']; 2713 $thumb_path = file_path_for_type($image_path, 'thumb'); 2714 $hd_path = file_path_for_type($image_path, 'high'); 2715 } 2716 2717 if (!is_valid_image_extension(get_extension($image_path))) 2699 2718 { 2700 2719 return new PwgError(403, "image can't be resized"); 2701 2720 } 2702 2721 2703 if ($params['type'] == 'thumbnail' and !empty($image['tn_ext'])) 2704 { 2705 trigger_event( 2722 $result = false; 2723 2724 if ($params['type'] == 'thumbnail' and file_exists($image_path)) 2725 { 2726 prepare_directory(dirname($thumb_path)); 2727 2728 $result = trigger_event( 2706 2729 'upload_thumbnail_resize', 2707 2730 false, 2708 $image ['path'],2709 get_thumbnail_path($image),2731 $image_path, 2732 $thumb_path, 2710 2733 $params['maxwidth'], 2711 2734 $params['maxheight'], … … 2715 2738 get_boolean($params['follow_orientation']) 2716 2739 ); 2717 return true; 2718 } 2719 elseif (!empty($image['has_high'])) 2720 { 2721 trigger_event( 2740 } 2741 elseif (file_exists($hd_path)) 2742 { 2743 $result = trigger_event( 2722 2744 'upload_image_resize', 2723 2745 false, 2724 file_path_for_type($image['path'], 'high'),2725 $image ['path'],2746 $hd_path, 2747 $image_path, 2726 2748 $params['maxwidth'], 2727 2749 $params['maxheight'], … … 2730 2752 ); 2731 2753 2732 $conf['use_exif'] = false; 2733 $conf['use_iptc'] = false; 2734 update_metadata(array($image['id'] => $image['path'])); 2735 2736 return true; 2737 } 2738 return false; 2754 if (!empty($image['has_high'])) 2755 { 2756 $conf['use_exif'] = false; 2757 $conf['use_iptc'] = false; 2758 update_metadata(array($image['id'] => $image['path'])); 2759 } 2760 } 2761 return $result; 2739 2762 } 2740 2763
Note: See TracChangeset
for help on using the changeset viewer.