本文整理汇总了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;
}
示例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];
}
示例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!"));
}
示例4: getAssetFilePath
/**
* @param AssetFileModel $asset
*
* @return string
*/
protected function getAssetFilePath(AssetFileModel $asset)
{
return $asset->getSource()->getSourceType()->getBasePath() . $asset->getFolder()->path . $asset->filename;
}