diff --git a/CHANGELOG.md b/CHANGELOG.md index de8e48b..6e4414b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Retcon Changelog +## 2.0.6 - 2018-08-05 +### Fixed +- Fixes an issue where Retcon would attempt to use Imager for transforms, even if Imager was not installed or deactivated + ## 2.0.5 - 2018-07-28 ### Fixed - Fixes a bug where the `transform` method would return an empty string if Retcon would fail to transform an image diff --git a/composer.json b/composer.json index 617b336..911e293 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mmikkel/retcon", "description": "Powerful Twig filters for mutating and querying HTML", "type": "craft-plugin", - "version": "2.0.5", + "version": "2.0.6", "keywords": [ "craft", "cms", diff --git a/src/Retcon.php b/src/Retcon.php index d42f250..cb250a0 100644 --- a/src/Retcon.php +++ b/src/Retcon.php @@ -117,10 +117,7 @@ function (Event $event) { ); } - /** - * @return \craft\base\Model|RetconSettings|null - */ - protected function createSettingsModel() + public function getSettings() { return new RetconSettings(); } diff --git a/src/library/RetconHelper.php b/src/library/RetconHelper.php index 5da6da0..40f0db9 100644 --- a/src/library/RetconHelper.php +++ b/src/library/RetconHelper.php @@ -116,7 +116,7 @@ public static function getTransformedImage(string $src, $transform, array $image $settings = Retcon::$plugin->getSettings(); // If we can use Imager, we need to do minimal work - if ($settings->useImager && Craft::$app->getPlugins()->getPlugin('imager')) { + if ($settings->useImager) { /** @var \aelvan\imager\Imager $imagerPlugin */ $imagerPlugin = Craft::$app->plugins->getPlugin('imager'); return $imagerPlugin->imager->transformImage($imageUrl, $transform, $imagerTransformDefaults, $imagerConfigOverrides); @@ -150,8 +150,8 @@ public static function getTransformedImage(string $src, $transform, array $image } // Get basepaths and URLs - $basePath = StringHelper::ensureRight(Craft::getAlias($settings->baseTransformPath), '/'); - $baseUrl = StringHelper::ensureRight(Craft::getAlias($settings->baseTransformUrl), '/'); + $basePath = StringHelper::ensureRight($settings->baseTransformPath, '/'); + $baseUrl = StringHelper::ensureRight($settings->baseTransformUrl, '/'); $siteUrl = StringHelper::ensureRight(UrlHelper::siteUrl(), '/'); $host = \parse_url($siteUrl, PHP_URL_HOST); diff --git a/src/models/RetconSettings.php b/src/models/RetconSettings.php index e138ef1..43fbad1 100644 --- a/src/models/RetconSettings.php +++ b/src/models/RetconSettings.php @@ -31,15 +31,20 @@ class RetconSettings extends Model */ public function __construct($config = []) { - $config = \array_merge($config, Craft::$app->getConfig()->getConfigFromFile('retcon')); - parent::__construct($config); - if (!empty($config)) { \Yii::configure($this, $config); } + $this->init(); + } + public function init() + { + parent::init(); + $this->useImager = $this->useImager && Craft::$app->getPlugins()->getPlugin('imager'); + $this->baseTransformPath = Craft::getAlias($this->baseTransformPath); + $this->baseTransformUrl = Craft::getAlias($this->baseTransformUrl); } }