Skip to content
This repository was archived by the owner on Jul 3, 2024. It is now read-only.

Commit faa17ef

Browse files
Fixed a few bugs & I think we’re good to go
1 parent 561c7e3 commit faa17ef

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

system/expressionengine/third_party/easy_cloudinary/pi.easy_cloudinary.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ class Easy_cloudinary {
3737
*/
3838
function __construct()
3939
{
40-
if ( isset( ee()->config['easy_cloudinary'] ) )
40+
# grab the config
41+
$this->cloudinary_config = ee()->config->item('easy_cloudinary');
42+
if ( $this->cloudinary_config !== NULL )
4143
{
42-
# grab the config
43-
$this->cloudinary_config = ee()->config['easy_cloudinary'];
44-
4544
# get the host name
4645
$http_host = strToLower( ee()->input->server('HTTP_HOST') );
4746
$ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
@@ -63,7 +62,7 @@ function __construct()
6362
*/
6463
function convert( $str='' )
6564
{
66-
$account = $this->cloudinary_config['account'];
65+
$cloud_name = $this->cloudinary_config['cloud_name'];
6766
$template = $this->cloudinary_config['template'];
6867

6968
# in case we have relative image paths
@@ -143,23 +142,27 @@ function convert( $str='' )
143142
# Format the src to include this domain is we don’t have it already
144143
if ( strpos( $src, $this->site_domain ) === FALSE )
145144
{
146-
if ( substr ( $src, 0, 1 ) == '/' )
147-
{
148-
$src = "{$this->site_domain}{$src}";
149-
}
150-
else
145+
# only modify if not a fully qualified domain
146+
if ( preg_match( "/^https?:\\/\\//", $src ) === 0 )
151147
{
152-
$src = "{$this->site_domain}{$current_path}{$src}";
148+
if ( substr( $src, 0, 1 ) == '/' )
149+
{
150+
$src = "{$this->site_domain}{$src}";
151+
}
152+
else
153+
{
154+
$src = "{$this->site_domain}{$current_path}{$src}";
155+
}
153156
}
154157
}
155158

156159
# build the new image
157160
$swap = array(
158-
'cloud_name' => $this->account,
161+
'cloud_name' => $cloud_name,
159162
'attributes' => implode( ' ', $attributes ),
160163
'image_url' => $src
161164
);
162-
$new_img = ee()->functions->var_swap( $this->template, $swap );
165+
$new_img = ee()->functions->var_swap( $template, $swap );
163166

164167
$str = str_replace( $original_img, $new_img, $str );
165168

0 commit comments

Comments
 (0)