Exemple #1
0
             continue;
         }
     }
 }
 if (!$imgUp->finish_upload(isset($admin_upload) ? 1 : null)) {
     if ($imgUp->error_code == 125) {
         user_feedback('error', '<b>' . $imgUp->info['full_name'] . '</b> ' . _T("site_upload_err") . ' .', 'filemove');
     }
     continue;
 }
 //Resize image if needed
 if ($settings['SET_RESIZE_IMG_ON']) {
     if (isset($_POST['new_width'][$i]) && !empty($_POST['new_width'][$i]) || isset($_POST['new_height'][$i]) && !empty($_POST['new_height'][$i])) {
         $imgUp->stretchSmallImages(true);
         if (!empty($_POST['new_width'][$i]) && !empty($_POST['new_height'][$i])) {
             $imgUp->resizeImage($_POST['new_width'][$i], $_POST['new_height'][$i], 'exact');
         } elseif (!empty($_POST['new_width'][$i]) && empty($_POST['new_height'][$i])) {
             $imgUp->resizeImage($_POST['new_width'][$i], $imgUp->info['width'], 'landscape');
         } elseif (empty($_POST['new_width'][$i]) && !empty($_POST['new_height'][$i])) {
             $imgUp->resizeImage($imgUp->info['height'], $_POST['new_height'][$i], 'portrait');
         }
         $imgUp->saveImage($imgUp->info['address'], 100, null, true);
         $imgUp->info['size'] = filesize($imgUp->info['address']);
         // get new image file size
         $imgUp->stretchSmallImages(false);
         // set it back to false
     }
 }
 // check for theme Settings
 $THUMB_OPTION = theme_setting('thumb_option', $THUMB_OPTION);
 $THUMB_MAX_WIDTH = theme_setting('thumb_max_width', $THUMB_MAX_WIDTH);
Exemple #2
0
	//Image Locations
	$large_image_location = $upload_path . $large_image_name . $file_ext;
	$thumb_image_location = $upload_path . $thumb_image_name . $file_ext;
	
	//Everything is ok, so we can upload the image.
	if (isset($_FILES['image']['name'])){
		move_uploaded_file($userfile_tmp, $large_image_location);
		chmod($large_image_location, 0777);
		
		$width = $upload->getWidth($large_image_location);
		$height = $upload->getHeight($large_image_location);
		//Scale the image if it is greater than the width set above
		if ($width > $max_width) {
			$scale = $max_width / $width;
			$uploaded = $upload->resizeImage($large_image_location,$width,$height,$scale);
		} else {
			$scale = 1;
			$uploaded = $upload->resizeImage($large_image_location,$width,$height,$scale);
		}

		//Delete the thumbnail file so the user can create a new one
		/*if (file_exists($thumb_image_location)) {
			unlink($thumb_image_location);
		}*/
	}

	if (file_exists($large_image_location)) {
		$thumb_photo_exists = $upload_path . $large_image_name . $file_ext;
		$large_photo_exists = $upload_path . $large_image_name . $file_ext;
	}