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


PHP ImageHelper类代码示例

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


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

示例1: RemoveFileOnly

 public static function RemoveFileOnly($pk, $fieldName)
 {
     $modelRemove = self::model()->findByPk($pk);
     if (is_null($modelRemove) || empty($modelRemove->{$fieldName})) {
         return;
     }
     $aDate = explode('-', $modelRemove->date_only);
     $pathUpload = ProGlobalEnquiry::$folderUpload . "/{$aDate['0']}/{$aDate['1']}/{$aDate['2']}";
     $ImageHelper = new ImageHelper();
     $ImageHelper->folder = '/' . $pathUpload;
     $ImageHelper->deleteFile($ImageHelper->folder . '/' . $modelRemove->{$fieldName});
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:12,代码来源:ProEnquiryGlobalFile.php

示例2: handleFileUpload

 /**
  * Override parent
  */
 function handleFileUpload($fileParameters, $id)
 {
     $filename = $this->fileDefaultName;
     if (array_key_exists($this->parameterFile, $fileParameters) and array_key_exists('name', $fileParameters[$this->parameterFile]) and $fileParameters[$this->parameterFile]['name'] != '') {
         $imageHelper = new ImageHelper();
         $filename = $imageHelper->upload($this->fileBasename, $id, $fileParameters[$this->parameterFile]);
         /*if ($filepath != "") {
         		$imageHelper = new SimpleImage();
         		$imageHelper->load($filepath);
         		$imageHelper->resize(100,100);
         		$imageHelper->save('../img/news/News-".$id."100x100.png');
         		}*/
     }
     return $filename;
 }
开发者ID:replicair,项目名称:Replicair-website,代码行数:18,代码来源:SlideshowController.php

示例3: actionDescription

 public function actionDescription()
 {
     Yii::app()->page->setInfo(array("description" => $this->description, "keyWord" => $this->keyWord));
     $id = 0;
     $class = $this->classModel;
     if (!empty($_GET["slug"])) {
         $model = $class::fetchBySlug(trim($_GET["slug"]));
         if ($model->id > 0) {
             $_GET["id"] = $model->id;
             $id = $model->id;
         }
     }
     $error = Yii::t("page", "Произошла ошибка перехода на страницу, проверьте правильно написания адреса страницы");
     if ($id > 0) {
         $item = CatalogFirmsService::fetch($id);
         if ($item->id > 0) {
             CCModelHelper::colCounter($item);
             // Картинки тура
             $images = ImageHelper::getImages($item);
             Yii::app()->page->title = $item->name . " - " . Yii::t("page", "услуги от компании");
             $this->render('description', array("item" => $item, "images" => $images, "firmsService" => CatalogFirmsService::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id AND id!=:id")->setParams(array(":firm_id" => $item->firm_id, ":id" => $item->id))->setCache(0)), "firmsItems" => CatalogFirmsItems::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("firm_id=:firm_id")->setParams(array(":firm_id" => $item->firm_id))->setCache(0))));
         } else {
             throw new CHttpException("", $error);
         }
     } else {
         throw new CHttpException("", $error);
     }
 }
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:28,代码来源:ServiceController.php

示例4: actionPrepareForCrop

 /**
  * Prepare asset for cropping.
  */
 public function actionPrepareForCrop()
 {
     $this->requireAjaxRequest();
     $elementId = craft()->request->getParam('elementId');
     // Get the asset file
     $asset = craft()->assets->getFileById($elementId);
     $source = $asset->getSource();
     $sourceType = $source->getSourceType();
     $file = $sourceType->getLocalCopy($asset);
     try {
         // Test if we will be able to perform image actions on this image
         if (!craft()->images->checkMemoryForImage($file)) {
             IOHelper::deleteFile($file);
             $this->returnErrorJson(Craft::t('The selected image is too large.'));
         }
         // Scale to fit 500x500 for fitting in CP modal
         craft()->images->loadImage($file)->scaleToFit(500, 500, false)->saveAs($file);
         list($width, $height) = ImageHelper::getImageSize($file);
         // If the file is in the format badscript.php.gif perhaps.
         if ($width && $height) {
             $html = craft()->templates->render('_components/tools/cropper_modal', array('imageUrl' => $asset->url, 'width' => $width, 'height' => $height, 'fileName' => $asset->filename));
             $this->returnJson(array('html' => $html));
         }
     } catch (Exception $exception) {
         $this->returnErrorJson($exception->getMessage());
     }
 }
开发者ID:boboldehampsink,项目名称:cropassets,代码行数:30,代码来源:CropAssetsController.php

示例5: actionDescription

 public function actionDescription()
 {
     Yii::app()->page->setInfo(array("description" => $this->description, "keyWord" => $this->keyWord));
     $id = 0;
     $class = $this->classModel;
     if (!empty($_GET["slug"])) {
         $model = $class::fetchBySlug(trim($_GET["slug"]));
         if ($model->id > 0) {
             $_GET["id"] = $model->id;
             $id = $model->id;
         } else {
             $arrId = explode("-", $_GET["slug"]);
             if (sizeof($arrId) > 0) {
                 $id = (int) $arrId[0];
             }
         }
     }
     $error = Yii::t("page", "Произошла ошибка перехода на страницу, проверьте правильно написания адреса страницы");
     if ($id > 0) {
         $item = CatalogTours::fetch($id);
         if ($item->id > 0) {
             LogHelper::saveCatLogTours($item->id);
             CCModelHelper::colCounter($item);
             // Картинки тура
             $images = ImageHelper::getImages($item);
             Yii::app()->page->title = $item->name . ", тур " . $item->category_id->name . ", " . $item->country_id->name;
             $this->render('description', array("item" => $item, "images" => $images, "otherTours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND country_id=:country_id AND id!=:id AND firm_id!=:firm_id")->setParams(array(":country_id" => $item->country_id->id, ":id" => $item->id, ":firm_id" => $item->firm_id->id))->setOrderBy("col DESC")->setLimit(6)), "firmsTours" => CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("image>'' AND firm_id=:firm_id AND id!=:id")->setParams(array(":firm_id" => $item->firm_id->id, ":id" => $item->id))->setOrderBy("col DESC")->setLimit(6)), "tourCount" => CatalogTours::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->country_id->id))), "firmCount" => CatalogFirms::count(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country")->setParams(array(":country" => $item->country_id->id)))));
         } else {
             throw new CHttpException("", $error);
         }
     } else {
         throw new CHttpException("", $error);
     }
 }
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:34,代码来源:ToursController.php

示例6: init

 public function init()
 {
     parent::init();
     $image = $this->params['content']->image;
     $image['filename'] = ImageHelper::resizeDown($image['filename'], $this->params['content']->width, $this->params['content']->height);
     $this->params['content']->image = $image;
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:7,代码来源:WidgetImage.php

示例7: getSize

 /**
  * Returns an array of the width and height of the image.
  *
  * @return array
  */
 public function getSize()
 {
     if (!isset($this->size)) {
         $size = ImageHelper::getImageSize($this->path);
         $this->size = array($size[0], $size[1]);
     }
     return $this->size;
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:13,代码来源:ImageVariable.php

示例8: actionDescription

 public function actionDescription()
 {
     Yii::app()->page->setInfo(array("description" => $this->description, "keyWord" => $this->keyWord));
     $id = 0;
     $class = $this->classModel;
     $slug = !empty($_GET["slug"]) ? $_GET["slug"] : "";
     if (!empty($_GET["slug"])) {
         $model = $class::fetchBySlug(trim($slug));
         if ($model->id > 0) {
             $_GET["id"] = $model->id;
             $id = $model->id;
         }
     }
     // Проверяем по ID
     if ($id == 0) {
         $ar = explode("-", $slug);
         if ((int) $ar[0] > 0) {
             $model = $class::fetch((int) $ar[0]);
             $id = $model->id;
         }
     }
     if ($id > 0) {
         if ($model->id > 0) {
             $item = $model;
         } else {
             $item = $class::fetch($id);
         }
         if ($item->id > 0) {
             $images = ImageHelper::getImages($item);
             $other = $class::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("category_id=:category_id AND id!=:id")->setParams(array(":category_id" => $item->category_id->id, ":id" => $item->id))->setOrderBy("id DESC")->setLimit(12));
             $tourCategory = $item->tour_category;
             if (!empty($tourCategory) && sizeof($tourCategory) > 0) {
                 $dopSQL = " AND ( ";
                 $m = 0;
                 foreach ($tourCategory as $tCategory) {
                     if ($m > 0) {
                         $dopSQL .= " OR ";
                     }
                     $dopSQL .= "category_id=" . $tCategory->id;
                     $m++;
                 }
                 $dopSQL .= ") ";
                 $tours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country_id " . $dopSQL)->setParams(array(":country_id" => $item->country_id->id))->setOrderBy("rating DESC")->setLimit(9));
             } elseif ($item->country_id->id > 0) {
                 $tours = CatalogTours::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("country_id=:country_id")->setParams(array(":country_id" => $item->country_id->id))->setOrderBy("rating DESC")->setLimit(10));
             } else {
                 $tours = array();
             }
             Yii::app()->page->title = $item->name;
             $this->render('description', array("item" => $item, "other" => $other, "images" => $images, "tours" => $tours, "hotelCount" => $class::count(DBQueryParamsClass::CreateParams()->setConditions("category_id=:category_id")->setParams(array(":category_id" => $item->category_id->id)))));
         } else {
             throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
         }
     } else {
         throw new CHttpException("Ошибка", Yii::t("page", "Ошибка перехода на страницу"));
     }
 }
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:57,代码来源:InfoController.php

示例9: getThumb

 public function getThumb($size = null, $crop = true)
 {
     if (is_string($size)) {
         $size = ['width' => 64, 'height' => 64];
     }
     $dir = pathinfo($this->getPk(), PATHINFO_DIRNAME);
     $name = pathinfo($this->getPk(), PATHINFO_BASENAME);
     return ImageHelper::thumb($dir, $name, $size, $crop)->getSrc();
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:9,代码来源:RemoteApiBehavior.php

示例10: deleteImage

 public function deleteImage($fieldName, $path, $oldImage)
 {
     if (!empty($oldImage)) {
         ImageHelper::deleteFile($path . '/' . $oldImage);
         if (array_key_exists($fieldName, $this->aImageSize) && is_array($this->aImageSize[$fieldName])) {
             $aSize = $this->aImageSize[$fieldName];
             foreach ($aSize as $key => $value) {
                 ImageHelper::deleteFile($path . '/' . $key . '/' . $oldImage);
             }
         }
     }
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:12,代码来源:MyActiveRecord.php

示例11: actionDescription

 public function actionDescription()
 {
     $slug = Yii::app()->request->getParam("slug", "");
     if (!empty($slug)) {
         $item = CatalogAttractions::fetchBySlug($slug);
         if ($item->id > 0) {
             Yii::app()->page->setTitle($item->name);
             $list = CatalogAttractions::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("city_id=:cid AND id!=:id")->setParams(array(":cid" => $item->city_id->id, ":id" => $item->id))->setLimit(4));
             $images = ImageHelper::getImages($item);
             $this->render("description", array("item" => $item, "other" => $list, "images" => $images));
         }
     }
 }
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:13,代码来源:AttractionsController.php

示例12: init

 public function init()
 {
     parent::init();
     $keys = array_keys($this->params['content']->images);
     $image = $this->params['content']->images[$keys[rand(0, count($keys) - 1)]];
     $image['filename'] = ImageHelper::resizeDown($image['filename'], $this->params['content']->width, $this->params['content']->height);
     $this->params['image'] = $image;
     if (isset($image['data'][Yii::app()->language . '_caption'])) {
         $this->params['caption'] = $image['data'][Yii::app()->language . '_caption'];
     } else {
         $this->params['caption'] = $this->params['widget']->title;
     }
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:13,代码来源:WidgetRandomimage.php

示例13: run

 public function run()
 {
     $val = $this->model->{$this->attribute};
     if (!$this->model->isNewRecord && $val) {
         $id = $this->id . get_class($this);
         $files_data = $this->model->uploadFiles();
         $attribute_data = $files_data[$this->attribute];
         $directory = trim($attribute_data['dir'], '/');
         $preview = ImageHelper::thumb($directory, $val, array('width' => null, 'height' => 128));
         $preview .= CHtml::ajaxLink('X', array('/main/helpAdmin/saveAttribute'), array('type' => 'post', 'data' => array('model' => get_class($this->model), 'id' => $this->model->primaryKey, 'attribute' => $this->attribute, 'value' => '', 'unlink_file' => $directory . '/' . $val), 'success' => 'js:function() {$("#' . $id . '").remove();}'), array('class' => 'btn btn-danger delete-img'));
         echo CHtml::tag('div', array('id' => $id), $preview);
     }
     echo CHtml::activeFileField($this->model, $this->attribute, $this->htmlOptions);
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:14,代码来源:FileWidget.php

示例14: preparePartnerSlides

 protected function preparePartnerSlides()
 {
     $slides = array();
     $data = Yii::app()->db->createCommand(sprintf('SELECT  p.title, ph.filename, ph.title photo_title, ph.description photo_description
                                                         FROM partners p 
                                                         LEFT JOIN gallery g ON g.`gallery_id` = p.gallery_id
                                                         LEFT JOIN photo ph ON ph.gallery_id = g.gallery_id
                                                         WHERE p.is_active = 1 AND p.partner_id <> %d AND (ph.is_top <> 1 OR ph.is_top IS NULL)
                                                         ORDER BY ph.sort_order DESC', Yii::app()->params['partner_id']))->queryAll();
     foreach ($data as $slide) {
         $slides[] = array('url' => ImageHelper::imageUrl('', $slide['filename']), 'content' => sprintf('<img src=\'%s\' alt\'%s\' title=\'%s\'></img>', ImageHelper::imageUrl('partner_footer_frontend', $slide['filename']), ContentHelper::prepareStr($slide['title']), ContentHelper::prepareStr($slide['title'])));
     }
     return $slides;
 }
开发者ID:andreyantonov78,项目名称:atmosphera,代码行数:14,代码来源:FrontendController.php

示例15: init

 public function init()
 {
     craft()->on('assets.onSaveAsset', function (Event $event) {
         $asset = $event->params['asset'];
         if (craft()->imageResizer->getSettings()->enabled) {
             // Only process if it's a new asset being saved.
             if ($event->params['isNewAsset']) {
                 // Is this a manipulatable image?
                 if (ImageHelper::isImageManipulatable(IOHelper::getExtension($asset->filename))) {
                     craft()->imageResizer->resize($asset);
                 }
             }
         }
     });
 }
开发者ID:kcolls,项目名称:ImageResizer,代码行数:15,代码来源:ImageResizerPlugin.php


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