Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Upload Helper
- *
- * @package helpers
- * @date 04:39 07/07/2011
- */
- class Helper_Upload {
- /**
- * Resize the image and create a thumb.
- *
- * @param array $file
- * @return void
- */
- public static function save_image($file)
- {
- // Get default config for resize
- \Config::load('upload','upload');
- // Validate the current file
- if ($file['error'] == \Upload::UPLOAD_ERR_OK)
- {
- $file_path = $file['saved_to'].DS.$file['saved_as'];
- // Resize the image
- // Clear the last image obj by calling factory first
- \Image::factory(null, $file_path)
- ->resize(\Config::get('upload.resize_w'), \Config::get('upload.resize_h'))
- ->save($file_path);
- // Create image thumb
- \Image::load($file_path)
- ->resize(\Config::get('upload.thumb_w'), \Config::get('upload.thumb_h'))
- ->save_pa('', '_thumb'); // You're genius!
- }
- }
- /**
- * Get image thumb file.
- *
- * @access public
- * @param string $image
- * @return string
- */
- public static function thumb_file($image)
- {
- $ext = $image['extension'];
- return substr($image['saved_to'], 0, -(strlen($ext) + 1)).'_thumb.'.$ext;
- }
- }
- /* End of file upload.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement