1.9.x compatibility
Foaly* [Fri, 20 Sep 2013 22:05:24 +0000 (23:05 +0100)]
ImageCompressor.module.php
action.ajax.php
inc/ImageCompressor.js
lib/class.imagecompressor_utils.php

index 5de7001..c2881f2 100644 (file)
@@ -87,7 +87,7 @@ class ImageCompressor extends CMSModule {
        }
        public function MinimumCMSVersion()
        {
-               return "1.10";
+               return "1.9.4";
        }
        public function InstallPostMessage()
        {
index 1296ed5..6720c87 100644 (file)
@@ -86,4 +86,5 @@ switch($params['action']) {
 header("Cache-Control: no-cache, must-revalidate");
 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
 echo json_encode($return);
+exit; // need this for 1.9.x
 ?>
\ No newline at end of file
index 6fc8eee..873b574 100644 (file)
@@ -65,7 +65,7 @@ var ImageCompressor = (function ($) {
                                $td = $row.find('td:last-child'),
                                mod_params = {
                                        'action': 'smush',
-                                       'source': $td.find('.smush').data('source'),
+                                       'source': $td.find('.smush').attr('data-source'),
                                        'path': $row.find('td:eq(1)').text()
                                };
 
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)