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


PHP AssetFileModel::getSource方法代码示例

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


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

示例1: _getPathsForLocalAsset

 /**
  * Get paths for a local asset
  *
  * @param AssetFileModel $image
  */
 private function _getPathsForLocalAsset(AssetFileModel $image)
 {
     $assetSourcePath = craft()->config->parseEnvironmentString($image->getSource()->settings['url']);
     if (strrpos($assetSourcePath, 'http') !== false) {
         $parsedUrl = parse_url($assetSourcePath);
         $assetSourcePath = $parsedUrl['path'];
     }
     $this->sourcePath = ImagerService::fixSlashes(craft()->config->parseEnvironmentString($image->getSource()->settings['path']) . $image->getFolder()->path);
     $this->targetPath = ImagerService::fixSlashes(craft()->imager->getSetting('imagerSystemPath') . $assetSourcePath . $image->getFolder()->path) . $image->id . '/';
     $this->targetUrl = craft()->imager->getSetting('imagerUrl') . ImagerService::fixSlashes($assetSourcePath . $image->getFolder()->path, true) . $image->id . '/';
     $this->sourceFilename = $this->targetFilename = $image->filename;
 }
开发者ID:martinleveille,项目名称:Imager-Craft,代码行数:17,代码来源:Imager_ImagePathsModel.php

示例2: getAssetFile

 /**
  * Gets a file by its asset.
  *
  * @param AssetFileModel $asset
  *
  * @return string
  */
 protected function getAssetFile(AssetFileModel $asset)
 {
     // Check if we have this filenname cached already
     if (!isset($this->assets[$asset->id])) {
         // Get asset source
         $source = $asset->getSource();
         // Get asset source type
         $sourceType = $source->getSourceType();
         // Get asset file
         $this->assets[$asset->id] = $sourceType->getLocalCopy($asset);
     }
     return $this->assets[$asset->id];
 }
开发者ID:boboldehampsink,项目名称:youtube,代码行数:20,代码来源:YouTubeService.php

示例3: detectAutoTransformFormat

 /**
  * Detect the auto web-safe format for the Assets file. Returns null, if the file is not an image.
  *
  * @param AssetFileModel $file
  *
  * @return mixed|string
  * @throws Exception
  */
 public function detectAutoTransformFormat(AssetFileModel $file)
 {
     if (in_array(mb_strtolower($file->getExtension()), ImageHelper::getWebSafeFormats())) {
         return $file->getExtension();
     } else {
         if ($file->kind == "image") {
             // The only reasonable way to check for transparency is with Imagick. If Imagick is not present, then
             // we fallback to jpg
             if (craft()->images->isGd() || !method_exists("Imagick", "getImageAlphaChannel")) {
                 return 'jpg';
             }
             $source = craft()->assetSources->populateSourceType($file->getSource());
             $localCopy = $source->getLocalCopy($file);
             $image = craft()->images->loadImage($localCopy);
             if ($image->isTransparent()) {
                 $format = 'png';
             } else {
                 $format = 'jpg';
             }
             if ($source->isRemote()) {
                 // Store for potential later use and queue for deletion if needed.
                 $file->setTransformSource($localCopy);
                 $this->queueSourceForDeletingIfNecessary($localCopy);
             } else {
                 // For local, though, we just delete the temp file.
                 IOHelper::deleteFile($localCopy);
             }
             return $format;
         }
     }
     throw new Exception(Craft::t("Tried to detect the appropriate image format for a non-image!"));
 }
开发者ID:JulesVan,项目名称:solutions-con,代码行数:40,代码来源:AssetTransformsService.php

示例4: getAssetFilePath

 /**
  * @param AssetFileModel $asset
  *
  * @return string
  */
 protected function getAssetFilePath(AssetFileModel $asset)
 {
     return $asset->getSource()->getSourceType()->getBasePath() . $asset->getFolder()->path . $asset->filename;
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:9,代码来源:SproutFormsService.php


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