Changeset 5957


Ignore:
Timestamp:
04/25/10 00:22:32 (9 years ago)
Author:
patdenice
Message:

Add triggers for image and thumbnail resizing.

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upload.inc.php

    r5089 r5957  
    1717// 
    1818// 4) register in database 
     19 
     20// add default event handler for image and thumbnail resize 
     21add_event_handler('upload_image_resize', 'pwg_image_resize', EVENT_HANDLER_PRIORITY_NEUTRAL, 6); 
     22add_event_handler('upload_thumbnail_resize', 'pwg_image_resize', EVENT_HANDLER_PRIORITY_NEUTRAL, 6); 
    1923 
    2024function add_uploaded_file($source_filepath, $original_filename=null, $categories=null, $level=null) 
     
    6165    $high_infos = pwg_image_infos($high_path); 
    6266     
    63     pwg_image_resize( 
     67    trigger_event('upload_image_resize', 
     68      false, 
    6469      $high_path, 
    6570      $file_path, 
     
    7681  prepare_directory($thumb_dir); 
    7782   
    78   pwg_image_resize( 
     83  trigger_event('upload_thumbnail_resize', 
     84    false, 
    7985    $file_path, 
    8086    $thumb_path, 
     
    170176} 
    171177 
    172 function pwg_image_resize($source_filepath, $destination_filepath, $max_width, $max_height, $quality) 
    173 { 
     178function pwg_image_resize($result, $source_filepath, $destination_filepath, $max_width, $max_height, $quality) 
     179{ 
     180  if ($result !== false) 
     181  { 
     182    //someone hooked us - so we skip 
     183    return $result; 
     184  } 
     185 
    174186  if (!function_exists('gd_info')) 
    175187  { 
  • trunk/admin/thumbnail.php

    r5920 r5957  
    3333// be smaller than original picture !) in the sub directory named 
    3434// "thumbnail". 
    35 function RatioResizeImg($path, $newWidth, $newHeight, $tn_ext) 
     35function RatioResizeImg($info, $path, $newWidth, $newHeight, $tn_ext) 
    3636{ 
    3737  global $conf, $lang, $page; 
     38 
     39  if ($info !== false) 
     40  { 
     41    //someone hooked us - so we skip 
     42    return $info; 
     43  } 
    3844 
    3945  if (!function_exists('gd_info')) 
     
    158164} 
    159165 
     166// add default event handler for thumbnail resize 
     167add_event_handler('thumbnail_resize', 'RatioResizeImg', EVENT_HANDLER_PRIORITY_NEUTRAL, 5); 
     168 
    160169// +-----------------------------------------------------------------------+ 
    161170// |                       template initialization                         | 
     
    252261       
    253262      $starttime = get_moment(); 
    254       if ($info = RatioResizeImg($path,$_POST['width'],$_POST['height'],'jpg')) 
     263      if ($info = trigger_event('thumbnail_resize', 
     264            false, 
     265            $path, 
     266            $_POST['width'], 
     267            $_POST['height'], 
     268            'jpg' 
     269            ) 
     270         ) 
    255271      { 
    256272        $endtime = get_moment(); 
Note: See TracChangeset for help on using the changeset viewer.