// get the name of the new file $newfilename = $uplo->get_newname(); $fullpath = $uplo->fullPathtoFile; // save a "zoomed in" or xtra-large version, not bigger than ZOOM_MAX if (defined('ZOOM_MAX_W') and defined('ZOOM_MAX_H')) { $zoom_file = $uplo->params["path"] . '/' . 'z_' . $newfilename; $stretch = new imagestretcher($fullpath); if ($stretch->shrink_to_fit(ZOOM_MAX_W, ZOOM_MAX_H)) { $res = $stretch->save_to_file($zoom_file); } else { // it was already smaller than zoom_max - so ignore it! copy($fullpath, $zoom_file); } $stretch->free(); } $img_dims = $uplo->get_img_dims(); // save "medium" or default image but not bigger than MAX_ if (defined('MAX_W') and defined('MAX_H')) { if ($uplo->imgwidth > MAX_W or $uplo->imgheight > MAX_H) { $stretch = new imagestretcher($fullpath); $stretch->shrink_to_fit(MAX_W, MAX_H); $stretch->save_to_file($fullpath); $img_dims = $stretch->get_img_dims(); $stretch->free(); } } // create a thumbnail right here: $needs_thumb = false; if (defined('THUMB_MAX_W') and defined('THUMB_MAX_H')) { $thumb1 = $uplo->save_thumbnail(THUMB_MAX_W, THUMB_MAX_H, 'shrink_to_fit'); $needs_thumb = true;
// we got one - use $uplo to check it and save it and create DB vals as needed $uplo->preserve_original_name = true; $uplo->setErrorHandling(PEAR_ERROR_RETURN); // tell $uplo what kind of image we expect and where to put it: $uplo->params(array('path' => CSHOP_MEDIA_FULLPATH, 'ws_path' => CSHOP_MEDIA_URLPATH) + $colmap[$upfile][3]); // set other possible params for uplo from the colmap attribs section [3] // todo something better */ $res = $uplo->save_upload(); if (PEAR::isError($res)) { $errs[] = $res->getMessage(); } else { // get the name of the new file $newfilename = $uplo->get_newname(); // create a thumbnail right here: // vals to be put in DB - will be given the rest of the column names below $upfiles[$upfile] = array('' => $newfilename, 'mimetype' => $uplo->get_filetype(), 'size' => $uplo->get_filesize(), 'dims' => $uplo->get_img_dims()); // call resizing or thumbnailing methods as needed ((((())))))))))))))))))))))) if (isset($uplo->params['thumb_method'])) { // todo $uplo should do this too $method = $uplo->params['thumb_method']; $stretch = new imagestretcher(CSHOP_MEDIA_FULLPATH . '/' . $newfilename); if (!method_exists($stretch, $method)) { $errs[] = "imagestretcher::{$method}() is not a valid method."; } else { $stretch->{$method}($uplo->params['thumb_w'], $uplo->params['thumb_h']); $thumb_name = $stretch->save_to_file(CSHOP_MEDIA_FULLPATH . '/_th_' . $newfilename, 'png'); $upfiles[$upfile]['thumb_name'] = $thumb_name; $upfiles[$upfile]['thumb_dims'] = $stretch->get_thumb_dims(); } } if (isset($uplo->params['resize_method'])) {
*/ } else { // we got one - use $uplo to check it and save it and create DB vals as needed $uplo->unique_filename = true; $uplo->preserve_original_name = true; $uplo->setErrorHandling(PEAR_ERROR_RETURN); // tell $uplo what kind of image we expect and where to put it: $uplo->params = $colmap[$upfile][3]; $res = $uplo->save_upload(); if (PEAR::isError($res)) { $errs[] = $res->getMessage(); } else { // get the name of the new file $newfilename = $uplo->get_newname(); // vals to be put in DB $upfiles[$upfile] = array('sFilename' => $newfilename, 'sType' => 'image', 'dtDate' => date('Y-m-d h:i'), 'img_dims' => $uplo->get_img_dims()); if ($upfile == 'imageid') { // create a thumbnail right here: $thumb1 = $uplo->save_thumbnail(THUMB_MAX_W, THUMB_MAX_H); if (PEAR::isError($thumb1)) { $errs[] = $thumb1->getMessage(); } else { // another upfile for the thumbnail image $upfiles['image_thumbid'] = array('sFilename' => $thumb1, 'sType' => 'image', 'dtDate' => date('Y-m-d h:i'), 'img_dims' => $uplo->get_thumb_dims()); } } } } } $imgcount = 0; /** try to insert or update image info to DB table media_prod **/