@@ -37,11 +37,10 @@ class Easy_cloudinary {
37
37
*/
38
38
function __construct ()
39
39
{
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 )
41
43
{
42
- # grab the config
43
- $ this ->cloudinary_config = ee ()->config ['easy_cloudinary ' ];
44
-
45
44
# get the host name
46
45
$ http_host = strToLower ( ee ()->input ->server ('HTTP_HOST ' ) );
47
46
$ ssl = isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] === 'on ' ;
@@ -63,7 +62,7 @@ function __construct()
63
62
*/
64
63
function convert ( $ str ='' )
65
64
{
66
- $ account = $ this ->cloudinary_config ['account ' ];
65
+ $ cloud_name = $ this ->cloudinary_config ['cloud_name ' ];
67
66
$ template = $ this ->cloudinary_config ['template ' ];
68
67
69
68
# in case we have relative image paths
@@ -143,23 +142,27 @@ function convert( $str='' )
143
142
# Format the src to include this domain is we don’t have it already
144
143
if ( strpos ( $ src , $ this ->site_domain ) === FALSE )
145
144
{
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 )
151
147
{
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
+ }
153
156
}
154
157
}
155
158
156
159
# build the new image
157
160
$ swap = array (
158
- 'cloud_name ' => $ this -> account ,
161
+ 'cloud_name ' => $ cloud_name ,
159
162
'attributes ' => implode ( ' ' , $ attributes ),
160
163
'image_url ' => $ src
161
164
);
162
- $ new_img = ee ()->functions ->var_swap ( $ this -> template , $ swap );
165
+ $ new_img = ee ()->functions ->var_swap ( $ template , $ swap );
163
166
164
167
$ str = str_replace ( $ original_img , $ new_img , $ str );
165
168
0 commit comments