1.9.x compatibility
[imagecompressor.git] / lib / class.imagecompressor_utils.php
index c88d886..9f3cb3a 100644 (file)
@@ -52,23 +52,19 @@ class imagecompressor_utils {
                }
                $response = fgets($f);
                fclose($f);
-
-               if($response == 'null')
+               if($response == null)
                {
                        return false;
                }
-
                if(function_exists('json_decode'))
                {
-                       $response = json_decode($response);
+                       return json_decode($response);
                }
                else
                {
                        $json = new Services_JSON();
-                       $response = $json->decode($response);
+                       return $json->decode($response);
                }
-
-               return $response;
        }
 
        static final protected function smushit_curl($url)
@@ -78,9 +74,17 @@ class imagecompressor_utils {
                curl_setopt($smushit, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($smushit, CURLOPT_URL, $url);
                curl_setopt($smushit, CURLOPT_USERAGENT, self::SMUSHIT_UA);
-               $request = curl_exec($smushit);
+               $response = curl_exec($smushit);
                curl_close($smushit);
-               return json_decode($request);
+               if(function_exists('json_decode'))
+               {
+                       return json_decode($response);
+               }
+               else
+               {
+                       $json = new Services_JSON();
+                       return $json->decode($response);
+               }
        }
 
        static final public function smushit_post($file_url)