From 129e9f30f2ea40d77efaef8a7546f70b485a8b56 Mon Sep 17 00:00:00 2001 From: Sindre Gulseth Date: Mon, 7 Dec 2015 09:56:28 +0100 Subject: [PATCH 1/5] Upgraded imboclient --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0a080aa..b875d59 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ } ], "require": { - "imbo/imboclient": "~1.0" + "imbo/imboclient": "~2.0" }, "autoload": { "classmap": [ From d2f651a3a56b9c438a8bbe6687d036599c658203 Mon Sep 17 00:00:00 2001 From: Sindre Gulseth Date: Mon, 7 Dec 2015 16:46:52 +0100 Subject: [PATCH 2/5] Return null if imbo-config is not set --- lib/core/DrPublishApiClient.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/core/DrPublishApiClient.php b/lib/core/DrPublishApiClient.php index 1f3e724..2f7b6bc 100644 --- a/lib/core/DrPublishApiClient.php +++ b/lib/core/DrPublishApiClient.php @@ -642,15 +642,20 @@ public static function resizeImboImage($src, $width, $height) $imboUrl = ImboImageUrl::factory($src); $imageIdentifier = $imboUrl->getImageIdentifier(); $transformations = $imboUrl->getQuery()->get('t'); + $imboClient = self::getImboClient(); - $imboUrl = self::getImboClient()->getImageUrl($imageIdentifier); - foreach ($transformations as $transformation) { - if (strpos($transformation, 'maxSize') === false) { - $imboUrl->addTransformation($transformation); + if ($imboClient) { + $imboUrl = $imboClient->getImageUrl($imageIdentifier); + foreach ($transformations as $transformation) { + if (strpos($transformation, 'maxSize') === false) { + $imboUrl->addTransformation($transformation); + } } + + return $imboUrl->maxSize($width, $height)->resize($width); } - return $imboUrl->maxSize($width, $height)->resize($width); + return null; } public static function setImboClient($imboClient) { @@ -660,8 +665,10 @@ public static function setImboClient($imboClient) { public static function getImboClient() { if (!self::$imboClient) { $imboConfig = self::getConfigOption('imbo'); - $imboClient = ImboClient\ImboClient::factory($imboConfig); - self::setImboClient($imboClient); + if ($imboConfig) { + $imboClient = ImboClient\ImboClient::factory($imboConfig); + self::setImboClient($imboClient); + } } return self::$imboClient; From 4b0ac1d668972c50aa8a1cce8bbd177c50b7b2cd Mon Sep 17 00:00:00 2001 From: Sindre Gulseth Date: Mon, 7 Dec 2015 16:47:00 +0100 Subject: [PATCH 3/5] Added static function to set imbo config --- lib/core/DrPublishApiClient.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/core/DrPublishApiClient.php b/lib/core/DrPublishApiClient.php index 2f7b6bc..470702c 100644 --- a/lib/core/DrPublishApiClient.php +++ b/lib/core/DrPublishApiClient.php @@ -674,6 +674,13 @@ public static function getImboClient() { return self::$imboClient; } + public static function setImboConfig($config) { + if (!is_array(self::$configs)) { + self::$configs = array(); + } + self::$configs['imbo'] = $config; + } + public function getCurlInfo() { return $this->curlInfo; From 17fe61caae9bf2f4e6202cf97a4e64db583142a4 Mon Sep 17 00:00:00 2001 From: Sindre Gulseth Date: Tue, 2 Feb 2016 11:35:24 +0100 Subject: [PATCH 4/5] Cast transformations to an array --- lib/core/DrPublishApiClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/DrPublishApiClient.php b/lib/core/DrPublishApiClient.php index 470702c..3a9b9e4 100644 --- a/lib/core/DrPublishApiClient.php +++ b/lib/core/DrPublishApiClient.php @@ -641,7 +641,7 @@ public static function resizeImboImage($src, $width, $height) { $imboUrl = ImboImageUrl::factory($src); $imageIdentifier = $imboUrl->getImageIdentifier(); - $transformations = $imboUrl->getQuery()->get('t'); + $transformations = (array) $imboUrl->getQuery()->get('t'); $imboClient = self::getImboClient(); if ($imboClient) { From ad04d594c2b581088fa100c0c0bbcb994fd71b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ketil=20=C3=98vreb=C3=B8?= Date: Mon, 11 Apr 2016 15:00:22 +0200 Subject: [PATCH 5/5] Ensure the original user in the IMBO url is maintained when resizing When resizing, a new URL is created with the username from the configuration. This causes problems for VGNett, as IMBO-images may have multiple sources. Hardcoding the user results in imag This change ensures the username from the original URL is kept when we generate the new URL. The originally configured user is reset once the URL has been generated. --- lib/core/DrPublishApiClient.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/core/DrPublishApiClient.php b/lib/core/DrPublishApiClient.php index 3a9b9e4..1ee0a60 100644 --- a/lib/core/DrPublishApiClient.php +++ b/lib/core/DrPublishApiClient.php @@ -645,7 +645,13 @@ public static function resizeImboImage($src, $width, $height) $imboClient = self::getImboClient(); if ($imboClient) { + $user = $imboUrl->getUser(); + $originalUser = $imboClient->getUser(); + if (!empty($user)) { + $imboClient->setUser($user); + } $imboUrl = $imboClient->getImageUrl($imageIdentifier); + $imboClient->setUser($originalUser); foreach ($transformations as $transformation) { if (strpos($transformation, 'maxSize') === false) { $imboUrl->addTransformation($transformation);