Skip to content

Commit

Permalink
Fixes an issue where Retcon would attempt to use Imager for transform…
Browse files Browse the repository at this point in the history
…s, even if Imager was not installed or deactivated. Bump to 2.0.6
  • Loading branch information
mmikkel committed Aug 5, 2018
1 parent ffb12fb commit 4cf83d5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions src/Retcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ function (Event $event) {
);
}

/**
* @return \craft\base\Model|RetconSettings|null
*/
protected function createSettingsModel()
public function getSettings()
{
return new RetconSettings();
}
Expand Down
6 changes: 3 additions & 3 deletions src/library/RetconHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 8 additions & 3 deletions src/models/RetconSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit 4cf83d5

Please sign in to comment.