/** * Initialize image properties * * Resets values in case this class is used in a loop * * @access public * @return void */ function clear() { $this->user_width = 0; $this->user_height = 0; $this->user_x_axis = ''; $this->user_y_axis = ''; return parent::clear(); }
/** * Initialize image properties * * Resets values in case this class is used in a loop * * @access public * @return void */ public function clear() { $result = parent::clear(); $this->user_width = 0; $this->user_height = 0; $this->user_x_axis = ''; $this->user_y_axis = ''; return $result; }
/** * * @param string|integer $id (Primary Key) * @param string $name * @param string $folder (posts/images) * @return boolean */ public static function upload($field, $id, $name, $folder, $config = array()) { $CI =& get_instance(); $ciConfig = $CI->config->item('utils'); $config['upload_path'] = $path = $ciConfig['upload_dir'] . $folder . '/'; $config['allowed_types'] = 'gif|jpg|png'; $config['file_name'] = $fileName = self::getFileName($id, self::IMAGE_ORIGINAL, $name); $CI->load->library('upload'); $CI->load->library('image_lib'); $upload = new CI_Upload($config); if (!$upload->do_upload($field)) { return $upload->display_errors('', ''); } else { $imageConfig = array('source_image' => $path . $fileName); foreach (array(self::IMAGE_LARGE, self::IMAGE_MEDIUM, self::IMAGE_SMALL) as $size) { $imageConfig['new_image'] = $path . self::getFileName($id, $size, $name); // list($imageConfig['width'], $imageConfig['height']) = explode('x', $ciConfig['image'][strtolower($size)]); list($imageConfig['width']) = explode('x', $ciConfig['image'][strtolower($size)]); $image = new CI_Image_lib(); $image->initialize($imageConfig); $image->resize(); $image->clear(); } $imageConfig['new_image'] = $path . self::getFileName($id, self::IMAGE_THUMB, $name); list($imageConfig['width'], $imageConfig['height']) = explode('x', $ciConfig['image'][strtolower(self::IMAGE_THUMB)]); $imageConfig['maintain_ratio'] = FALSE; $image = new CI_Image_lib(); $image->initialize($imageConfig); $image->resize(); $image->clear(); return TRUE; } }