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


PHP Varien_Image::keeptransparency方法代码示例

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


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

示例1: saveAction

 public function saveAction()
 {
     $session = Mage::getSingleton('adminhtml/session');
     if ($data = $this->getRequest()->getPost()) {
         try {
             $path = Mage::getBaseDir('media') . DS . 'productattachments';
             if (isset($_FILES['category_image']['name']) && $_FILES['category_image']['name'] != '') {
                 //echo '<pre>';print_r($_FILES['event_image']);exit;
                 try {
                     /* Starting upload */
                     $uploader = new Varien_File_Uploader('category_image');
                     // Any extention would work
                     $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
                     $uploader->setAllowRenameFiles(false);
                     // Set the file upload mode
                     // false -> get the file directly in the specified folder
                     // true -> get the file in the product like folders
                     //	(file.jpg will go in something like /media/f/i/file.jpg)
                     $uploader->setFilesDispersion(false);
                     // We set media as the upload dir
                     $uploader->save($path, $_FILES['category_image']['name']);
                     $varImg = new Varien_Image($path . DS . $_FILES['category_image']['name']);
                     $varImg->constrainOnly(TRUE);
                     $varImg->keepAspectRatio(FALSE);
                     $varImg->keepFrame(TRUE);
                     $varImg->keeptransparency(FALSE);
                     $varImg->backgroundColor(array(255, 255, 255));
                     // WHITE BACKGROUND
                     $image_name = $_FILES['category_image']['name'];
                     $varImg->resize(400, 400);
                     $varImg->save($path, $image_name);
                     $data['category_image'] = 'productattachments' . DS . $image_name;
                 } catch (Exception $e) {
                     Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productattachments')->__('Error: ' . $e->getMessage()));
                     Mage::getSingleton('adminhtml/session')->setFormData($data);
                     $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
                     return;
                 }
             }
             $id = $this->getRequest()->getParam('id');
             // checking URL key
             if (!isset($data['category_url_key']) || !$data['category_url_key']) {
                 $data['category_url_key'] = $data['category_name'];
             }
             $data['category_url_key'] = FME_Productattachments_Helper_Data::nameToUrlKey($data['category_url_key']);
             $model = Mage::getModel('productattachments/productcats')->setData($data)->setId($id);
             if ($model->isUrlKeyUsed()) {
                 $session->addError($this->__('URL key is not unique within category store views'));
                 $session->setKBaseCategoryData($data);
                 $this->_redirect('*/*/edit', array('id' => $id));
                 return;
             }
             $model->save();
             $session->addSuccess($this->__('Category was successfully saved'));
             //$session->setKBaseCategoryData(false);
             if ($this->getRequest()->getParam('back')) {
                 $this->_redirect('*/*/edit', array('id' => $model->getId()));
                 return;
             }
             $this->_redirect('*/*/');
             return;
         } catch (Exception $e) {
             Mage::logException($e);
             $session->addError($e->getMessage());
             $session->setKBaseCategoryData($data);
             $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
             return;
         }
     } else {
         $session->addError($this->__('Unable to find an category to save'));
         $this->_redirect('*/*/');
     }
 }
开发者ID:guohuadeng,项目名称:aototechweb,代码行数:73,代码来源:ProductcatsController.php


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