Version Notes
Handle errors from service
Download this release
Release Info
| Developer | Tiny |
| Extension | Tiny_Compresss_Images |
| Version | 1.0.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0 to 1.0.1
app/code/community/Tiny/CompressImages/Model/Observer.php
CHANGED
|
@@ -52,14 +52,18 @@ class Tiny_CompressImages_Model_Observer
|
|
| 52 |
$width = $imageObject->getWidth();
|
| 53 |
$height = $imageObject->getHeight();
|
| 54 |
$compressor = Tiny_Compress::get_compressor($apiKey);
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
} else {
|
| 64 |
$logDescription = "No API key found for compression.";
|
| 65 |
}
|
| 52 |
$width = $imageObject->getWidth();
|
| 53 |
$height = $imageObject->getHeight();
|
| 54 |
$compressor = Tiny_Compress::get_compressor($apiKey);
|
| 55 |
+
try {
|
| 56 |
+
$details = $compressor->compress_file($newFile);
|
| 57 |
+
$logDescription =
|
| 58 |
+
"Variant " . $destinationSubdir .
|
| 59 |
+
" allowed " . $allowCompression .
|
| 60 |
+
" width " . $width .
|
| 61 |
+
" height " . $height .
|
| 62 |
+
" API " . $apiKey .
|
| 63 |
+
" JSON response " . json_encode($details);
|
| 64 |
+
} catch (Tiny_Exception $e) {
|
| 65 |
+
$logDescription = $e->get_error() . ': ' . $e->getMessage();
|
| 66 |
+
}
|
| 67 |
} else {
|
| 68 |
$logDescription = "No API key found for compression.";
|
| 69 |
}
|
lib/TinyCompress/class-tiny-compress.php
CHANGED
|
@@ -79,7 +79,7 @@ abstract class Tiny_Compress {
|
|
| 79 |
$headers = explode("\r\n", $headers);
|
| 80 |
}
|
| 81 |
foreach ($headers as $header) {
|
| 82 |
-
if (substr($header, 0, 10) === "
|
| 83 |
return substr($header, 10);
|
| 84 |
}
|
| 85 |
}
|
| 79 |
$headers = explode("\r\n", $headers);
|
| 80 |
}
|
| 81 |
foreach ($headers as $header) {
|
| 82 |
+
if (strtolower(substr($header, 0, 10)) === "location: ") {
|
| 83 |
return substr($header, 10);
|
| 84 |
}
|
| 85 |
}
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Tiny_Compresss_Images</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="https://www.gnu.org/licenses/gpl-2.0.html">GPL v2 or later</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -10,11 +10,11 @@
|
|
| 10 |
<description>Make your webshop faster by compressing your JPEG and PNG images.
|
| 11 |

|
| 12 |
This plugin automatically optimizes your images by integrating with the popular image compression services TinyJPG and TinyPNG.</description>
|
| 13 |
-
<notes>
|
| 14 |
<authors><author><name>TinyPNG</name><user>TinyPNG</user><email>info@tinypng.com</email></author></authors>
|
| 15 |
-
<date>2015-
|
| 16 |
-
<time>
|
| 17 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Tiny_CompressImages.xml" hash="13fbe2b1d6381daadcf798266785a451"/></dir></target><target name="magelib"><dir name="TinyCompress"><file name="README.md" hash="4ae1886316de0c8dea5d1990b9649cd4"/><file name="cacert.pem" hash="d7f7dd7e3ede3e323fc0e09381f16caf"/><file name="class-tiny-compress-curl.php" hash="7ecabcea793ae179063c1dc93a2509a9"/><file name="class-tiny-compress-fopen.php" hash="ade5462599afcb9d7b49aca1982a148c"/><file name="class-tiny-compress.php" hash="
|
| 18 |
<compatible/>
|
| 19 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Tiny_Compresss_Images</name>
|
| 4 |
+
<version>1.0.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="https://www.gnu.org/licenses/gpl-2.0.html">GPL v2 or later</license>
|
| 7 |
<channel>community</channel>
|
| 10 |
<description>Make your webshop faster by compressing your JPEG and PNG images.
|
| 11 |

|
| 12 |
This plugin automatically optimizes your images by integrating with the popular image compression services TinyJPG and TinyPNG.</description>
|
| 13 |
+
<notes>Handle errors from service</notes>
|
| 14 |
<authors><author><name>TinyPNG</name><user>TinyPNG</user><email>info@tinypng.com</email></author></authors>
|
| 15 |
+
<date>2015-05-15</date>
|
| 16 |
+
<time>13:56:57</time>
|
| 17 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Tiny_CompressImages.xml" hash="13fbe2b1d6381daadcf798266785a451"/></dir></target><target name="magelib"><dir name="TinyCompress"><file name="README.md" hash="4ae1886316de0c8dea5d1990b9649cd4"/><file name="cacert.pem" hash="d7f7dd7e3ede3e323fc0e09381f16caf"/><file name="class-tiny-compress-curl.php" hash="7ecabcea793ae179063c1dc93a2509a9"/><file name="class-tiny-compress-fopen.php" hash="ade5462599afcb9d7b49aca1982a148c"/><file name="class-tiny-compress.php" hash="e74709f18b1efd623e5c3945b8cbcf47"/><file name="class-tiny-exception.php" hash="9a9ae877854ee523d68c1ad9c875c319"/><file name="class-tiny-php.php" hash="7ab90f953a98a6ff2becc0d5aaea3f66"/><dir name="config"><file name="tinypng-api.ini" hash="c876771cfd9609aa517fc6a677f0d329"/></dir></dir></target><target name="magecommunity"><dir name="Tiny"><dir name="CompressImages"><dir name="Model"><file name="Observer.php" hash="890f0300645e8002bc28715a7b514bd3"/><dir name="Product"><file name="Image.php" hash="d022a2c075571e90919716b49602aefc"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ec3a27c4fca2924c2bcace7cf2a33fb4"/><file name="config.xml" hash="af64144c88706151e633a178475a46fd"/><file name="system.xml" hash="77bf25c48a20ea171b11776beaa7165b"/></dir></dir></dir></target></contents>
|
| 18 |
<compatible/>
|
| 19 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
</package>
|
