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


PHP ImageHelper::getWebSafeFormats方法代码示例

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


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

示例1: actionSaveTransform

 /**
  * Saves an asset source.
  */
 public function actionSaveTransform()
 {
     $this->requirePostRequest();
     $transform = new AssetTransformModel();
     $transform->id = craft()->request->getPost('transformId');
     $transform->name = craft()->request->getPost('name');
     $transform->handle = craft()->request->getPost('handle');
     $transform->width = craft()->request->getPost('width');
     $transform->height = craft()->request->getPost('height');
     $transform->mode = craft()->request->getPost('mode');
     $transform->position = craft()->request->getPost('position');
     $transform->quality = craft()->request->getPost('quality');
     $transform->format = craft()->request->getPost('format');
     if (empty($transform->format)) {
         $transform->format = null;
     }
     $errors = false;
     if (empty($transform->width) && empty($transform->height)) {
         craft()->userSession->setError(Craft::t('You must set at least one of the dimensions.'));
         $errors = true;
     }
     if (!empty($transform->quality) && (!is_numeric($transform->quality) || $transform->quality > 100 || $transform->quality < 1)) {
         craft()->userSession->setError(Craft::t('Quality must be a number between 1 and 100 (included).'));
         $errors = true;
     }
     if (!empty($transform->format) && !in_array($transform->format, ImageHelper::getWebSafeFormats())) {
         craft()->userSession->setError(Craft::t('That is not an allowed format.'));
         $errors = true;
     }
     if (!$errors) {
         // Did it save?
         if (craft()->assetTransforms->saveTransform($transform)) {
             craft()->userSession->setNotice(Craft::t('Transform saved.'));
             $this->redirectToPostedUrl($transform);
         } else {
             craft()->userSession->setError(Craft::t('Couldn’t save source.'));
         }
     }
     // Send the transform back to the template
     craft()->urlManager->setRouteVariables(array('transform' => $transform));
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:44,代码来源:AssetTransformsController.php

示例2: _getThumbExtension

 /**
  * Return the thumbnail extension for a file.
  *
  * @param AssetFileModel $file
  *
  * @return string
  */
 private function _getThumbExtension(AssetFileModel $file)
 {
     // For non-web-safe formats we go with jpg.
     if (!in_array(mb_strtolower(IOHelper::getExtension($file->filename)), ImageHelper::getWebSafeFormats())) {
         if ($file->getExtension() == 'svg' && craft()->images->isImagick()) {
             return 'png';
         }
         return 'jpg';
     } else {
         return $file->getExtension();
     }
 }
开发者ID:JulesVan,项目名称:solutions-con,代码行数:19,代码来源:AssetTransformsService.php

示例3: _getThumbExtension

 /**
  * Return the thumbnail extension for a file.
  *
  * @param AssetFileModel $file
  *
  * @return string
  */
 private function _getThumbExtension(AssetFileModel $file)
 {
     // For non-web-safe formats we go with jpg.
     if (!in_array(IOHelper::getExtension($file->filename), ImageHelper::getWebSafeFormats())) {
         return 'jpg';
     } else {
         return $file->getExtension();
     }
 }
开发者ID:blairrorani,项目名称:everlearning,代码行数:16,代码来源:AssetTransformsService.php


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