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


PHP ImageHelper::createThumbnail方法代码示例

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


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

示例1: _processMedia

 /**
  * Process media files
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return
  * @since 		4.0
  */
 private function _processMedia()
 {
     $jinput = JFactory::getApplication()->input;
     $csvilog = $jinput->get('csvilog', null, null);
     $template = $jinput->get('template', null, null);
     // Check if any image handling needs to be done
     if ($template->get('process_image', 'image', false)) {
         if (!is_null($this->file_url)) {
             // Image handling
             $imagehelper = new ImageHelper();
             // Verify the original image
             if ($imagehelper->isRemote($this->file_url)) {
                 $original = $this->file_url;
                 $remote = true;
                 if ($template->get('save_images_on_server', 'image')) {
                     switch ($this->file_type) {
                         case 'category':
                             $base = $template->get('file_location_category_images', 'path');
                             break;
                         default:
                             $base = $template->get('file_location_product_images', 'path');
                             break;
                     }
                 } else {
                     $base = '';
                 }
                 $full_path = $base;
             } else {
                 // Create the full file_url path
                 switch ($this->file_type) {
                     case 'category':
                         $base = $template->get('file_location_category_images', 'path');
                         break;
                     default:
                         $base = $template->get('file_location_product_images', 'path');
                         break;
                 }
                 // Check if the image contains the image path
                 $dirname = dirname($this->file_url);
                 if (strpos($base, $dirname) !== false) {
                     $image = basename($this->file_url);
                 }
                 $original = $base . $this->file_url;
                 $remote = false;
                 // Get subfolders
                 $path_parts = pathinfo($original);
                 $full_path = $path_parts['dirname'] . '/';
                 $csvilog->addDebug(JText::sprintf('COM_CSVI_CREATED_FILE_URL', $original));
                 $remote = false;
             }
             // Generate image names
             $file_details = $imagehelper->ProcessImage($original, $full_path);
             // Process the file details
             if ($file_details['exists'] && $file_details['isimage']) {
                 $media = array();
                 $this->file_title = $this->file_title ? $this->file_title : $this->file_url;
                 $this->file_description = $this->file_description ? $this->file_description : $this->file_url;
                 $this->file_meta = $this->file_meta ? $this->file_meta : $this->file_url;
                 $this->file_mimetype = $file_details['mime_type'];
                 $this->file_type = $this->file_type;
                 $this->file_is_product_image = $this->file_type == 'product' ? 1 : 0;
                 $this->file_is_downloadable = $this->file_is_downloadable ? $this->file_is_downloadable : 0;
                 $this->file_is_forSale = $this->file_is_forSale ? $this->file_is_forSale : 0;
                 $this->file_url = empty($file_details['output_path']) ? $file_details['output_name'] : $file_details['output_path'] . $file_details['output_name'];
                 // Create the thumbnail
                 if ($template->get('thumb_create', 'image')) {
                     // Get the subfolder structure
                     $thumb_path = str_ireplace($base, '', $full_path);
                     if (empty($this->file_url_thumb)) {
                         $this->file_url_thumb = 'resized/' . $thumb_path . basename($this->file_url);
                     }
                     if (!$remote) {
                         $original = $this->file_url;
                     }
                     $this->file_url_thumb = $imagehelper->createThumbnail($original, $base, $this->file_url_thumb);
                 } else {
                     if (empty($this->file_url_thumb)) {
                         $this->file_url_thumb = $this->file_url;
                     }
                 }
             }
         }
     }
 }
开发者ID:spiridonov-oa,项目名称:SheinCandles,代码行数:96,代码来源:mediaimport.php

示例2: _processMedia

 /**
  * Process media files
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return
  * @since 		4.0
  */
 private function _processMedia()
 {
     $jinput = JFactory::getApplication()->input;
     $template = $jinput->get('template', null, null);
     $csvilog = $jinput->get('csvilog', null, null);
     // Check if any image handling needs to be done
     if ($template->get('process_image', 'image', false)) {
         if (!is_null($this->file_url) || $template->get('auto_generate_image_name', 'image', false)) {
             // Create an array of images to process
             $images = explode('|', $this->file_url);
             $thumbs = explode('|', $this->file_url_thumb);
             $titles = explode('|', $this->file_title);
             $descriptions = explode('|', $this->file_description);
             $metas = explode('|', $this->file_meta);
             $ordering = 1;
             // Image handling
             $imagehelper = new ImageHelper();
             foreach ($images as $key => $image) {
                 $image = trim($image);
                 // Create image name if needed
                 if (count($images) == 1) {
                     $img_counter = 0;
                 } else {
                     $img_counter = $key + 1;
                 }
                 if ($template->get('auto_generate_image_name', 'image')) {
                     $this->_createImageName($img_counter);
                 }
                 if (!empty($image)) {
                     // Verify the original image
                     if ($imagehelper->isRemote($image)) {
                         $original = $image;
                         $remote = true;
                         $full_path = $template->get('file_location_product_images', 'path');
                     } else {
                         $original = $template->get('file_location_product_images', 'path') . $image;
                         $remote = false;
                         // Get subfolders
                         $path_parts = pathinfo($original);
                         $full_path = $path_parts['dirname'] . '/';
                     }
                     // Generate image names
                     if ($template->get('auto_generate_image_name', 'image')) {
                         $file_details = $imagehelper->ProcessImage($original, $full_path, $this->product_full_image_output);
                     } else {
                         $file_details = $imagehelper->ProcessImage($original, $full_path);
                     }
                     // Process the file details
                     if ($file_details['exists']) {
                         // Check if the image is an external image
                         if (substr($file_details['name'], 0, 4) == 'http') {
                             $csvilog->AddStats('incorrect', 'COM_CSVI_VM_NOSUPPORT_URL');
                         } else {
                             $title = isset($titles[$key]) ? $titles[$key] : $file_details['output_name'];
                             $description = isset($descriptions[$key]) ? $descriptions[$key] : '';
                             $meta = isset($metas[$key]) ? $metas[$key] : '';
                             $media = array();
                             $media['virtuemart_vendor_id'] = $this->virtuemart_vendor_id;
                             if ($template->get('autofill', 'image')) {
                                 $media['file_title'] = $file_details['output_name'];
                                 $media['file_description'] = $file_details['output_name'];
                                 $media['file_meta'] = $file_details['output_name'];
                             } else {
                                 $media['file_title'] = $title;
                                 $media['file_description'] = $description;
                                 $media['file_meta'] = $meta;
                             }
                             $media['file_mimetype'] = $file_details['mime_type'];
                             $media['file_type'] = 'product';
                             $media['file_is_product_image'] = 1;
                             $media['file_is_downloadable'] = 0;
                             $media['file_is_forSale'] = 0;
                             $media['file_url'] = empty($file_details['output_path']) ? $file_details['output_name'] : $file_details['output_path'] . $file_details['output_name'];
                             $media['published'] = $this->published;
                             // Create the thumbnail
                             if ($file_details['isimage']) {
                                 $thumb = isset($thumbs[$key]) ? $thumbs[$key] : null;
                                 if ($template->get('thumb_create', 'image')) {
                                     $thumb_sizes = getimagesize(JPATH_SITE . '/' . $media['file_url']);
                                     if (empty($thumb)) {
                                         $thumb = 'resized/' . basename($media['file_url']);
                                     }
                                     if ($thumb_sizes[0] < 1024 || $thumb_sizes[1] < 768) {
                                         $media['file_url_thumb'] = $imagehelper->createThumbnail($media['file_url'], $template->get('file_location_product_images', 'path'), $thumb);
                                     } else {
                                         $media['file_url_thumb'] = '';
                                     }
                                 } else {
//.........这里部分代码省略.........
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:101,代码来源:productimport.php

示例3: _processMedia

 /**
  * Process media files
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return
  * @since 		4.0
  */
 private function _processMedia()
 {
     $jinput = JFactory::getApplication()->input;
     $template = $jinput->get('template', null, null);
     // Check if any image handling needs to be done
     if ($template->get('process_image', 'image', false)) {
         if (!is_null($this->file_url)) {
             // Image handling
             $imagehelper = new ImageHelper();
             // Verify the original image
             if ($imagehelper->isRemote($this->file_url)) {
                 $original = $this->file_url;
                 $remote = true;
             } else {
                 $original = $template->get('file_location_category_images', 'path') . $this->file_url;
                 $remote = false;
             }
             $file_details = $imagehelper->ProcessImage($original, $template->get('file_location_category_images', 'path'));
             // Process the file details
             if ($file_details['exists'] && $file_details['isimage']) {
                 $media = array();
                 $media['virtuemart_vendor_id'] = $this->virtuemart_vendor_id;
                 $media['file_title'] = $this->file_url;
                 $media['file_description'] = $this->file_url;
                 $media['file_meta'] = $this->file_url;
                 $media['file_mimetype'] = $file_details['mime_type'];
                 $media['file_type'] = 'category';
                 $media['file_is_product_image'] = 0;
                 $media['file_is_downloadable'] = 0;
                 $media['file_is_forSale'] = 0;
                 $media['file_url'] = empty($file_details['output_path']) ? $file_details['output_name'] : $file_details['output_path'] . $file_details['output_name'];
                 $media['published'] = $this->published;
                 // Create the thumbnail
                 if ($template->get('thumb_create', 'image')) {
                     if (empty($this->file_url_thumb)) {
                         $this->file_url_thumb = 'resized/' . basename($media['file_url']);
                     }
                     if ($remote) {
                         $original = $this->file_url;
                     } else {
                         $original = $media['file_url'];
                     }
                     $media['file_url_thumb'] = $imagehelper->createThumbnail($original, $template->get('file_location_category_images', 'path'), $this->file_url_thumb);
                 } else {
                     $media['file_url_thumb'] = empty($this->file_url_thumb) ? $media['file_url'] : $this->file_url_thumb;
                 }
                 // Bind the media data
                 $this->_medias->bind($media);
                 // Check if the media image already exists
                 $this->_medias->check();
                 // Store the media data
                 if ($this->_medias->store()) {
                     // Store the product image relation
                     $data = array();
                     $data['virtuemart_category_id'] = $this->virtuemart_category_id;
                     $data['virtuemart_media_id'] = $this->_medias->virtuemart_media_id;
                     $this->_category_medias->bind($data);
                     if (!$this->_category_medias->check()) {
                         $this->_category_medias->store();
                     }
                 }
             }
         }
     }
 }
开发者ID:spiridonov-oa,项目名称:SheinCandles,代码行数:77,代码来源:categoryimport.php

示例4: _processMedia

 /**
  * Process property images
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return
  * @since 		4.3
  */
 private function _processMedia($image)
 {
     $jinput = JFactory::getApplication()->input;
     $template = $jinput->get('template', null, null);
     $csvilog = $jinput->get('csvilog', null, null);
     // Check if any image handling needs to be done
     if ($template->get('process_image', 'image', false)) {
         if (!is_null($this->{$image})) {
             // Image handling
             $imagehelper = new ImageHelper();
             // Verify the original image
             if ($imagehelper->isRemote($this->{$image})) {
                 $original = $this->{$image};
                 $remote = true;
                 $full_path = $template->get('file_location_property_images', 'path');
             } else {
                 $original = $template->get('file_location_property_images', 'path') . $this->{$image};
                 $remote = false;
                 // Get subfolders
                 $path_parts = pathinfo($original);
                 $full_path = $path_parts['dirname'] . '/';
             }
             // Generate image names
             $file_details = $imagehelper->ProcessImage($original, $full_path);
             // Process the file details
             if ($file_details['exists'] && $file_details['isimage']) {
                 // Check if the image is an external image
                 if (substr($file_details['name'], 0, 4) == 'http') {
                     $csvilog->AddStats('incorrect', 'COM_CSVI_EZREALTY_NOSUPPORT_URL');
                 } else {
                     $this->{$image} = $file_details['output_name'];
                     // Create the thumbnail
                     if ($template->get('thumb_create', 'image')) {
                         $imagehelper->createThumbnail($file_details['output_path'] . $this->{$image}, $template->get('file_location_property_images', 'path') . 'th/', $this->{$image});
                     }
                 }
             }
         }
     }
 }
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:52,代码来源:propertyimport.php

示例5: _processMedia

 /**
  * Process property images
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return
  * @since 		4.3
  */
 private function _processMedia($image)
 {
     $jinput = JFactory::getApplication()->input;
     $template = $jinput->get('template', null, null);
     $csvilog = $jinput->get('csvilog', null, null);
     // Check if any image handling needs to be done
     if ($template->get('process_image', 'image', false)) {
         if (!is_null($this->{$image})) {
             // Create an array of images to process
             $images = explode('|', $this->{$image});
             $titles = explode('|', $this->file_title);
             $descriptions = explode('|', $this->file_description);
             $order = explode('|', $this->file_ordering);
             $ordering = 1;
             $max_width = $template->get('resize_max_width', 'image', 1024);
             $max_height = $template->get('resize_max_height', 'image', 768);
             // Image handling
             $imagehelper = new ImageHelper();
             foreach ($images as $key => $image) {
                 $image = trim($image);
                 // Create image name if needed
                 if (count($images) == 1) {
                     $img_counter = 0;
                 } else {
                     $img_counter = $key + 1;
                 }
                 if (!empty($image)) {
                     // Verify the original image
                     if ($imagehelper->isRemote($image)) {
                         $original = $image;
                         $remote = true;
                         $full_path = $template->get('file_location_property_images', 'path');
                     } else {
                         $original = $template->get('file_location_property_images', 'path') . $image;
                         $remote = false;
                         // Get subfolders
                         $path_parts = pathinfo($original);
                         $full_path = $path_parts['dirname'] . '/';
                     }
                     // Generate image names
                     $file_details = $imagehelper->ProcessImage($original, $full_path);
                     // Process the file details
                     if ($file_details['exists'] && $file_details['isimage']) {
                         // Check if the image is an external image
                         $title = isset($titles[$key]) ? $titles[$key] : $file_details['output_name'];
                         $description = isset($descriptions[$key]) ? $descriptions[$key] : '';
                         $data = array();
                         $data['propid'] = $this->id;
                         $data['fname'] = $file_details['output_name'];
                         $data['title'] = $title;
                         $data['description'] = $description;
                         $data['ordering'] = isset($order[$key]) && !empty($order[$key]) ? $order[$key] : $ordering;
                         if (substr($file_details['name'], 0, 4) == 'http') {
                             if (is_null($this->_images)) {
                                 $csvilog->AddStats('incorrect', 'COM_CSVI_EZREALTY_NOSUPPORT_URL');
                             } else {
                                 // External images are supported now but needs to be stored with separate data
                                 if (substr($file_details['output_path'], -1) == '/') {
                                     $data['path'] = substr($file_details['output_path'], 0, -1);
                                 } else {
                                     $data['path'] = $file_details['output_path'];
                                 }
                             }
                         } else {
                             $this->{$image} = $file_details['output_name'];
                             // Create the thumbnail
                             if ($template->get('thumb_create', 'image')) {
                                 $imagehelper->createThumbnail($file_details['output_path'] . $this->{$image}, $template->get('file_location_property_images', 'path') . 'th/', $this->{$image});
                             }
                         }
                         // Store the property image relation
                         $this->_images->bind($data);
                         if (!$this->_images->check()) {
                             if ($this->_images->store()) {
                                 $csvilog->addDebug('COM_CSVI_STORE_PROPERTY_IMAGE', true);
                                 $ordering++;
                                 $this->_images->reset();
                             }
                         } else {
                             $csvilog->addDebug('Property image relation already exists');
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:alesconti,项目名称:FF_2015,代码行数:99,代码来源:propertyimport.php

示例6: _processMedia

 /**
  * Process media files
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return
  * @since 		4.0
  */
 private function _processMedia()
 {
     $jinput = JFactory::getApplication()->input;
     $template = $jinput->get('template', null, null);
     $csvilog = $jinput->get('csvilog', null, null);
     // Check if any image handling needs to be done
     if ($template->get('process_image', 'image', false)) {
         if (!is_null($this->file_url) || $template->get('auto_generate_image_name', 'image', false)) {
             // Image handling
             $imagehelper = new ImageHelper();
             // Get the image path
             $imgpath = $template->get('file_location_product_images', 'path');
             if ($template->get('auto_generate_image_name', 'image')) {
                 $this->_createImageName();
             }
             // Verify the original image
             if ($imagehelper->isRemote($this->file_url)) {
                 $original = $this->file_url;
                 $remote = true;
                 $full_path = $imgpath;
             } else {
                 $remote = false;
                 // Check if the image contains the image path
                 $dirname = dirname($this->file_url);
                 if (strpos($imgpath, $dirname) !== false) {
                     $image = basename($this->file_url);
                 }
                 $original = $imgpath . $this->file_url;
                 $remote = false;
                 // Get subfolders
                 $path_parts = pathinfo($original);
                 $full_path = $path_parts['dirname'] . '/';
             }
             // Generate image names
             if ($template->get('auto_generate_image_name', 'image')) {
                 $file_details = $imagehelper->ProcessImage($original, $full_path, $this->product_full_image_output);
             } else {
                 $file_details = $imagehelper->ProcessImage($original, $full_path);
             }
             // Process the file details
             if ($file_details['exists'] && $file_details['isimage']) {
                 // Check if the image is an external image
                 if (substr($file_details['name'], 0, 4) == 'http') {
                     $csvilog->AddStats('incorrect', 'COM_CSVI_VM_NOSUPPORT_URL');
                 } else {
                     $media = array();
                     $media['virtuemart_vendor_id'] = $this->virtuemart_vendor_id;
                     $media['file_title'] = $this->file_title ? $this->file_title : $this->file_url;
                     $media['file_description'] = $this->file_description;
                     $media['file_meta'] = $this->file_meta;
                     $media['file_mimetype'] = $file_details['mime_type'];
                     $media['file_type'] = 'product';
                     $media['file_is_product_image'] = 1;
                     $media['file_is_downloadable'] = 0;
                     $media['file_is_forSale'] = 0;
                     $media['file_url'] = empty($file_details['output_path']) ? $file_details['output_name'] : $file_details['output_path'] . $file_details['output_name'];
                     // Create the thumbnail
                     if ($template->get('thumb_create', 'image')) {
                         // Get the subfolder structure
                         $thumb_path = str_ireplace($imgpath, '', $full_path);
                         if (empty($this->file_url_thumb)) {
                             $this->file_url_thumb = 'resized/' . $thumb_path . basename($media['file_url']);
                         }
                         if ($remote) {
                             $original = $this->file_url;
                         } else {
                             $original = $media['file_url'];
                         }
                         $media['file_url_thumb'] = $imagehelper->createThumbnail($original, $imgpath, $this->file_url_thumb);
                     } else {
                         $media['file_url_thumb'] = empty($this->file_url_thumb) ? $media['file_url'] : $this->file_url_thumb;
                         if (substr($media['file_url_thumb'], 0, 4) == 'http') {
                             $csvilog->addDebug(JText::sprintf('COM_CSVI_RESET_THUMB_NOHTTP', $media['file_url_thumb']));
                             $media['file_url_thumb'] = '';
                         }
                     }
                     // Bind the media data
                     $this->_medias->bind($media);
                     // Check if the media image already exists
                     $this->_medias->check();
                     // Store the media data
                     if ($this->_medias->store()) {
                         // Store the product image relation
                         $data = array();
                         $data['virtuemart_product_id'] = $this->virtuemart_product_id;
                         $data['virtuemart_media_id'] = $this->_medias->virtuemart_media_id;
                         $this->_product_medias->bind($data);
                         if (!$this->_product_medias->check()) {
//.........这里部分代码省略.........
开发者ID:spiridonov-oa,项目名称:SheinCandles,代码行数:101,代码来源:productimport.php

示例7: _processMedia

 /**
  * Process media files
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return
  * @since 		5.8
  */
 private function _processMedia()
 {
     $jinput = JFactory::getApplication()->input;
     $template = $jinput->get('template', null, null);
     $csvilog = $jinput->get('csvilog', null, null);
     // Check if any image handling needs to be done
     if ($template->get('process_image', 'image', false)) {
         if (!is_null($this->fname)) {
             $max_width = $template->get('resize_max_width', 'image', 1024);
             $max_height = $template->get('resize_max_height', 'image', 768);
             // Image handling
             $imagehelper = new ImageHelper();
             $image = trim($this->fname);
             if (!empty($image)) {
                 // Verify the original image
                 if ($imagehelper->isRemote($image)) {
                     $original = $image;
                     $remote = true;
                     $full_path = $template->get('file_location_property_images', 'path');
                 } else {
                     $original = $template->get('file_location_property_images', 'path') . $image;
                     $remote = false;
                     // Get subfolders
                     $path_parts = pathinfo($original);
                     $full_path = $path_parts['dirname'] . '/';
                 }
                 // Generate image names
                 $file_details = $imagehelper->ProcessImage($original, $full_path);
                 // Process the file details
                 if ($file_details['exists'] && $file_details['isimage']) {
                     // Check if the image is an external image
                     $title = isset($this->title) ? $this->title : $file_details['output_name'];
                     $data = array();
                     $data['propid'] = $this->propid;
                     $data['fname'] = $file_details['output_name'];
                     $data['title'] = $title;
                     $data['description'] = $this->description;
                     $data['ordering'] = $this->ordering;
                     if (substr($file_details['name'], 0, 4) == 'http') {
                         if (is_null($this->_images)) {
                             $csvilog->AddStats('incorrect', 'COM_CSVI_EZREALTY_NOSUPPORT_URL');
                         } else {
                             // External images are supported now but needs to be stored with separate data
                             if (substr($file_details['output_path'], -1) == '/') {
                                 $data['path'] = substr($file_details['output_path'], 0, -1);
                             } else {
                                 $data['path'] = $file_details['output_path'];
                             }
                         }
                     } else {
                         $this->fname = $file_details['output_name'];
                         // Create the thumbnail
                         if ($template->get('thumb_create', 'image')) {
                             $imagehelper->createThumbnail($file_details['output_path'] . $this->fname, $template->get('file_location_property_images', 'path') . 'th/', $this->fname);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:alesconti,项目名称:FF_2015,代码行数:73,代码来源:imageimport.php


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