當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。