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