当前位置: 首页>>代码示例>>PHP>>正文


PHP CI::image_lib方法代码示例

本文整理汇总了PHP中CI::image_lib方法的典型用法代码示例。如果您正苦于以下问题:PHP CI::image_lib方法的具体用法?PHP CI::image_lib怎么用?PHP CI::image_lib使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CI的用法示例。


在下文中一共展示了CI::image_lib方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload_image

 public function upload_image()
 {
     $config['upload_path'] = 'uploads/wysiwyg/images';
     $config['allowed_types'] = 'gif|jpg|png';
     \CI::load()->library('upload', $config);
     if (!\CI::upload()->do_upload('file')) {
         $error = array('error' => \CI::upload()->display_errors('', ''));
         echo stripslashes(json_encode($error));
     } else {
         $data = \CI::upload()->data();
         //upload successful generate a thumbnail
         $config['image_library'] = 'gd2';
         $config['source_image'] = 'uploads/wysiwyg/images/' . $data['file_name'];
         $config['new_image'] = 'uploads/wysiwyg/thumbnails/' . $data['file_name'];
         $config['create_thumb'] = FALSE;
         $config['maintain_ratio'] = TRUE;
         $config['width'] = 75;
         $config['height'] = 50;
         \CI::load()->library('image_lib', $config);
         \CI::image_lib()->resize();
         $data = array('filelink' => base_url('uploads/wysiwyg/images/' . $data['file_name']), 'filename' => $data['file_name']);
         echo stripslashes(json_encode($data));
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:24,代码来源:AdminWysiwyg.php

示例2: product_image_upload

 public function product_image_upload()
 {
     $data['file_name'] = false;
     $data['error'] = false;
     $config['allowed_types'] = 'gif|jpg|png';
     //$config['max_size']   = config_item('size_limit');
     $config['upload_path'] = 'uploads/images/full';
     $config['encrypt_name'] = true;
     $config['remove_spaces'] = true;
     \CI::load()->library('upload', $config);
     if (\CI::upload()->do_upload()) {
         $upload_data = \CI::upload()->data();
         \CI::load()->library('image_lib');
         $config['image_library'] = 'gd2';
         $config['source_image'] = 'uploads/images/full/' . $upload_data['file_name'];
         $config['new_image'] = 'uploads/images/medium/' . $upload_data['file_name'];
         $config['maintain_ratio'] = TRUE;
         $config['width'] = 600;
         $config['height'] = 500;
         \CI::image_lib()->initialize($config);
         \CI::image_lib()->resize();
         \CI::image_lib()->clear();
         //small image
         $config['image_library'] = 'gd2';
         $config['source_image'] = 'uploads/images/medium/' . $upload_data['file_name'];
         $config['new_image'] = 'uploads/images/small/' . $upload_data['file_name'];
         $config['maintain_ratio'] = TRUE;
         $config['width'] = 235;
         $config['height'] = 235;
         \CI::image_lib()->initialize($config);
         \CI::image_lib()->resize();
         \CI::image_lib()->clear();
         //cropped thumbnail
         $config['image_library'] = 'gd2';
         $config['source_image'] = 'uploads/images/small/' . $upload_data['file_name'];
         $config['new_image'] = 'uploads/images/thumbnails/' . $upload_data['file_name'];
         $config['maintain_ratio'] = TRUE;
         $config['width'] = 150;
         $config['height'] = 150;
         \CI::image_lib()->initialize($config);
         \CI::image_lib()->resize();
         \CI::image_lib()->clear();
         $data['file_name'] = $upload_data['file_name'];
     }
     if (\CI::upload()->display_errors() != '') {
         $data['error'] = \CI::upload()->display_errors();
     }
     $this->partial('iframe/product_image_uploader', $data);
 }
开发者ID:vandona,项目名称:v3,代码行数:49,代码来源:AdminProducts.php

示例3: form


//.........这里部分代码省略.........
     foreach ($data['groups'] as $group) {
         \CI::form_validation()->set_rules('enabled_' . $group->id, lang('enabled') . '(' . $group->name . ')', 'trim|numeric');
     }
     // validate the form
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('category_form', $data);
     } else {
         $uploaded = \CI::upload()->do_upload('image');
         if ($id) {
             //delete the original file if another is uploaded
             if ($uploaded) {
                 if ($data['image'] != '') {
                     $file = [];
                     $file[] = 'uploads/images/full/' . $data['image'];
                     $file[] = 'uploads/images/medium/' . $data['image'];
                     $file[] = 'uploads/images/small/' . $data['image'];
                     $file[] = 'uploads/images/thumbnails/' . $data['image'];
                     foreach ($file as $f) {
                         //delete the existing file if needed
                         if (file_exists($f)) {
                             unlink($f);
                         }
                     }
                 }
             }
         }
         if (!$uploaded) {
             $data['error'] = \CI::upload()->display_errors();
             if ($_FILES['image']['error'] != 4) {
                 $data['error'] .= \CI::upload()->display_errors();
                 $this->view('category_form', $data);
                 return;
                 //end script here if there is an error
             }
         } else {
             $image = \CI::upload()->data();
             $save['image'] = $image['file_name'];
             \CI::load()->library('image_lib');
             //this is the larger image
             $config['image_library'] = 'gd2';
             $config['source_image'] = 'uploads/images/full/' . $save['image'];
             $config['new_image'] = 'uploads/images/medium/' . $save['image'];
             $config['maintain_ratio'] = TRUE;
             $config['width'] = 600;
             $config['height'] = 500;
             \CI::image_lib()->initialize($config);
             \CI::image_lib()->resize();
             \CI::image_lib()->clear();
             //small image
             $config['image_library'] = 'gd2';
             $config['source_image'] = 'uploads/images/medium/' . $save['image'];
             $config['new_image'] = 'uploads/images/small/' . $save['image'];
             $config['maintain_ratio'] = TRUE;
             $config['width'] = 300;
             $config['height'] = 300;
             \CI::image_lib()->initialize($config);
             \CI::image_lib()->resize();
             \CI::image_lib()->clear();
             //cropped thumbnail
             $config['image_library'] = 'gd2';
             $config['source_image'] = 'uploads/images/small/' . $save['image'];
             $config['new_image'] = 'uploads/images/thumbnails/' . $save['image'];
             $config['maintain_ratio'] = TRUE;
             $config['width'] = 150;
             $config['height'] = 150;
             \CI::image_lib()->initialize($config);
             \CI::image_lib()->resize();
             \CI::image_lib()->clear();
         }
         \CI::load()->helper('text');
         //first check the slug field
         $slug = \CI::input()->post('slug');
         //if it's empty assign the name field
         if (empty($slug) || $slug == '') {
             $slug = \CI::input()->post('name');
         }
         $slug = url_title(convert_accented_characters($slug), 'dash', TRUE);
         if ($id) {
             $slug = \CI::Categories()->validate_slug($slug, $category->id);
         } else {
             $slug = \CI::Categories()->validate_slug($slug);
         }
         $save['id'] = $id;
         $save['name'] = \CI::input()->post('name');
         $save['description'] = \CI::input()->post('description');
         $save['excerpt'] = \CI::input()->post('excerpt');
         $save['parent_id'] = intval(\CI::input()->post('parent_id'));
         $save['sequence'] = intval(\CI::input()->post('sequence'));
         $save['seo_title'] = \CI::input()->post('seo_title');
         $save['meta'] = \CI::input()->post('meta');
         $save['slug'] = $slug;
         foreach ($data['groups'] as $group) {
             $save['enabled_' . $group->id] = \CI::input()->post('enabled_' . $group->id);
         }
         \CI::Categories()->save($save);
         \CI::session()->set_flashdata('message', lang('message_category_saved'));
         //go back to the category list
         redirect('admin/categories');
     }
 }
开发者ID:buzkall,项目名称:GoCart3,代码行数:101,代码来源:AdminCategories.php


注:本文中的CI::image_lib方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。