Beispiel #1
0
 /** -----------------------------------
     /**  Create image thumbnail
     /** -----------------------------------*/
 function create_thumb()
 {
     global $IN, $DSP, $LANG, $PREFS, $LANG, $DB;
     if ($_POST['width_unit'] == 'percent') {
         $_POST['width'] = ceil($_POST['width'] / 100 * $_POST['width_orig']);
     }
     if ($_POST['height_unit'] == 'percent') {
         $_POST['height'] = ceil($_POST['height'] / 100 * $_POST['height_orig']);
     }
     foreach ($_POST as $key => $val) {
         ${$key} = $val;
     }
     //print_r($_POST); exit;
     if ($width == $width_orig and $height == $height_orig) {
         return $DSP->error_message($LANG->line('image_size_not_different'));
     }
     if ($width != $width_orig or $height_orig != $height) {
         $query = $DB->query("SELECT * FROM exp_upload_prefs WHERE id = '" . $DB->escape_str($id) . "'");
         $thumb_prefix = $PREFS->ini('thumbnail_prefix') == '' ? 'thumb' : $PREFS->ini('thumbnail_prefix');
         /** --------------------------------
         			/**  Invoke the Image Lib Class
         			/** --------------------------------*/
         require PATH_CORE . 'core.image_lib' . EXT;
         $IM = new Image_lib();
         /** --------------------------------
         			/**  Resize the image
         			/** --------------------------------*/
         $res = $IM->set_properties(array('resize_protocol' => $PREFS->ini('image_resize_protocol'), 'libpath' => $PREFS->ini('image_library_path'), 'thumb_prefix' => $source == 'orig' ? '' : $thumb_prefix, 'file_path' => $query->row['server_path'], 'file_name' => $file_name, 'dst_width' => $width, 'dst_height' => $height, 'maintain_ratio' => FALSE));
         if ($res === FALSE or !$IM->image_resize()) {
             return $IM->show_error();
         }
     }
     $this->finalize_uploaded_file(array('id' => $id, 'field_group' => $field_group, 'orig_name' => $file_name, 'file_name' => $IM->thumb_name, 'is_image' => 1, 'step' => 2, 'source' => $source));
 }