-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from cloudinary/v2.9.7
V2.9.7
- Loading branch information
Showing
12 changed files
with
253 additions
and
54 deletions.
There are no files selected for viewing
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
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
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
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
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
79 changes: 79 additions & 0 deletions
79
app/code/community/Cloudinary/Cloudinary/Model/Catalog/Template/Filter.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
use CloudinaryExtension\CloudinaryImageProvider; | ||
use CloudinaryExtension\Image; | ||
use CloudinaryExtension\Image\ImageFactory; | ||
use CloudinaryExtension\UrlGenerator; | ||
|
||
/** | ||
* Catalog Template Filter Model | ||
* | ||
* @category Mage | ||
* @package Mage_Catalog | ||
* @author Magento Core Team <core@magentocommerce.com> | ||
* @todo Needs to be reimplemented to get rid of the copypasted methods | ||
*/ | ||
class Cloudinary_Cloudinary_Model_Catalog_Template_Filter extends Mage_Catalog_Model_Template_Filter | ||
{ | ||
/** | ||
* @var ImageFactory | ||
*/ | ||
private $imageFactory; | ||
|
||
/** | ||
* @var UrlGenerator | ||
*/ | ||
private $urlGenerator; | ||
|
||
/** | ||
* @var Configuration | ||
*/ | ||
private $configuration; | ||
|
||
public function __construct() | ||
{ | ||
$this->configuration = Mage::getModel('cloudinary_cloudinary/configuration'); | ||
if ($this->configuration->isEnabled()) { | ||
$this->imageFactory = new ImageFactory( | ||
$this->configuration, | ||
Mage::getModel('cloudinary_cloudinary/synchronizationChecker') | ||
); | ||
|
||
$this->urlGenerator = new UrlGenerator( | ||
$this->configuration, | ||
CloudinaryImageProvider::fromConfiguration($this->configuration) | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Retrieve media file URL directive | ||
* | ||
* @param array $construction | ||
* @return string | ||
* @see Mage_Core_Model_Email_Template_Filter::mediaDirective() method has been copypasted | ||
*/ | ||
public function mediaDirective($construction) | ||
{ | ||
if (!$this->configuration->isEnabled()) { | ||
return parent::mediaDirective($construction); | ||
} | ||
|
||
$imagePath = $this->getImagePath($construction[2]); | ||
|
||
$image = $this->imageFactory->build( | ||
$imagePath, | ||
function () use ($construction) { | ||
return parent::mediaDirective($construction); | ||
} | ||
); | ||
|
||
return $this->urlGenerator->generateFor($image); | ||
} | ||
|
||
private function getImagePath($directiveParams) | ||
{ | ||
$params = $this->_getIncludeParameters($directiveParams); | ||
return $params['url']; | ||
} | ||
} |
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
Oops, something went wrong.