Created
September 7, 2017 21:48
-
-
Save mattcdavis1/2ca495fea90f3aad55e678893b606f8b to your computer and use it in GitHub Desktop.
Craft Transform Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Copy a transform for a file from source location to target location. | |
* | |
* @param AssetFileModel $file The assetFileModel that has the transform to copy. | |
* @param string $targetFolderPath The target folder path. | |
* @param AssetTransformIndexModel $source The source transform index data. | |
* @param AssetTransformIndexModel $target The destination transform index data. | |
* | |
* @return mixed | |
*/ | |
public function copyTransform(AssetFileModel $file, $targetFolderPath, AssetTransformIndexModel $source, AssetTransformIndexModel $target) | |
{ | |
$sourceTransformPath = $file->folderPath.craft()->assetTransforms->getTransformSubpath($file, $source); | |
$targetTransformPath = $targetFolderPath.craft()->assetTransforms->getTransformSubpath($file, $target); | |
if ($sourceTransformPath == $targetTransformPath) | |
{ | |
return true; | |
} | |
return $this->copySourceFile($sourceTransformPath, $targetTransformPath); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @inheritDoc BaseAssetSourceType::copySourceFile() | |
* | |
* @param $sourceUri | |
* @param $targetUri | |
* | |
* @return bool | |
*/ | |
protected function copySourceFile($sourceUri, $targetUri) | |
{ | |
if ($sourceUri == $targetUri) | |
{ | |
return true; | |
} | |
$bucket = $this->getSettings()->bucket; | |
if (is_null($this->_s3)) { | |
$this->_prepareForRequests(); | |
} | |
return (bool) @$this->_s3->copyObject($bucket, $sourceUri, $bucket, $targetUri, $this->_getACL()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment