Version Notes
Stability improvements
Download this release
Release Info
Developer | Nekkra UG |
Extension | Kraken_Image_Optimizer |
Version | 2.0.6 |
Comparing to | |
See all releases |
Code changes from version 2.0.5 to 2.0.6
- app/code/local/Welance/Kraken/Block/Product/Image.php +1 -1
- app/code/local/Welance/Kraken/Helper/Api.php +9 -2
- app/code/local/Welance/Kraken/Helper/Data.php +52 -6
- app/code/local/Welance/Kraken/controllers/KrakenController.php +4 -1
- app/design/adminhtml/default/default/template/kraken/images/media.phtml +12 -0
- app/design/adminhtml/default/default/template/kraken/images/skin.phtml +12 -0
- app/design/frontend/base/default/layout/kraken.xml +0 -13
- app/design/frontend/base/default/template/kraken/product/image.phtml +0 -9
- js/kraken/optimize.js +2 -2
- package.xml +5 -5
- skin/adminhtml/default/default/kraken/kraken-tile.png +0 -0
app/code/local/Welance/Kraken/Block/Product/Image.php
CHANGED
@@ -23,7 +23,7 @@ class Welance_Kraken_Block_Product_Image extends Mage_Catalog_Block_Product_View
|
|
23 |
$productImagesCount = count($productImages);
|
24 |
|
25 |
foreach ($productImages as $productImage) {
|
26 |
-
$query .= "'%"
|
27 |
|
28 |
$i++;
|
29 |
|
23 |
$productImagesCount = count($productImages);
|
24 |
|
25 |
foreach ($productImages as $productImage) {
|
26 |
+
$query .= "'%".addslashes($productImage)."%'";
|
27 |
|
28 |
$i++;
|
29 |
|
app/code/local/Welance/Kraken/Helper/Api.php
CHANGED
@@ -41,8 +41,15 @@ class Welance_Kraken_Helper_Api extends Mage_Core_Helper_Abstract
|
|
41 |
|
42 |
public function krakenRequest($data, $url)
|
43 |
{
|
44 |
-
|
45 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
if (isset($data['file'])) {
|
48 |
$client->setFileUpload($data['file'],'file');
|
41 |
|
42 |
public function krakenRequest($data, $url)
|
43 |
{
|
44 |
+
|
45 |
+
$config = array(
|
46 |
+
'adapter' => 'Zend_Http_Client_Adapter_Curl',
|
47 |
+
'curloptions' => array(
|
48 |
+
CURLOPT_USERAGENT =>
|
49 |
+
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36"
|
50 |
+
)
|
51 |
+
);
|
52 |
+
$client = new Zend_Http_Client($url,$config);
|
53 |
|
54 |
if (isset($data['file'])) {
|
55 |
$client->setFileUpload($data['file'],'file');
|
app/code/local/Welance/Kraken/Helper/Data.php
CHANGED
@@ -161,10 +161,13 @@ class Welance_Kraken_Helper_Data extends Mage_Core_Helper_Abstract
|
|
161 |
if ($imageCollectionSize > 0) {
|
162 |
foreach ($imageCollection as $krakenImage) {
|
163 |
try {
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
168 |
} catch (Exception $e) {
|
169 |
Mage::throwException($e->getMessage());
|
170 |
}
|
@@ -275,7 +278,7 @@ class Welance_Kraken_Helper_Data extends Mage_Core_Helper_Abstract
|
|
275 |
|
276 |
|
277 |
/**
|
278 |
-
*
|
279 |
*/
|
280 |
|
281 |
public function deletePendingEntries()
|
@@ -294,7 +297,50 @@ class Welance_Kraken_Helper_Data extends Mage_Core_Helper_Abstract
|
|
294 |
$writeConnection->query($deleteQuery);
|
295 |
}
|
296 |
}
|
|
|
297 |
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
300 |
}
|
161 |
if ($imageCollectionSize > 0) {
|
162 |
foreach ($imageCollection as $krakenImage) {
|
163 |
try {
|
164 |
+
$backupFile = $backupDir . DS . $krakenImage->getPath() . DS . $krakenImage->getImageName();
|
165 |
+
if(is_file($backupFile)){
|
166 |
+
copy(
|
167 |
+
$backupFile,
|
168 |
+
Mage::getBaseDir() . DS . $krakenImage->getPath() . DS . $krakenImage->getImageName()
|
169 |
+
);
|
170 |
+
}
|
171 |
} catch (Exception $e) {
|
172 |
Mage::throwException($e->getMessage());
|
173 |
}
|
278 |
|
279 |
|
280 |
/**
|
281 |
+
* delete entries, which started with the upload but did not finish
|
282 |
*/
|
283 |
|
284 |
public function deletePendingEntries()
|
297 |
$writeConnection->query($deleteQuery);
|
298 |
}
|
299 |
}
|
300 |
+
}
|
301 |
|
302 |
+
/**
|
303 |
+
* check if image in Database exits
|
304 |
+
* if not remove it from Database
|
305 |
+
*/
|
306 |
+
public function removeDeletedImagesFromDatabase()
|
307 |
+
{
|
308 |
+
$types = array(Welance_Kraken_Model_Abstract::TYPE_MEDIA, Welance_Kraken_Model_Abstract::TYPE_SKIN);
|
309 |
+
|
310 |
+
foreach ($types as $type) {
|
311 |
+
$resource = Mage::getSingleton('core/resource');
|
312 |
+
$readConnection = $resource->getConnection('core_read');
|
313 |
+
$table = $resource->getTableName('welance_kraken/images_'.$type);
|
314 |
+
$query = "SELECT * FROM {$table}";
|
315 |
+
$entries = $readConnection->fetchAll($query);
|
316 |
+
|
317 |
+
if (count($entries) > 0) {
|
318 |
+
$this->_cleanUpImages($entries,$table);
|
319 |
+
}
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* @param array $entries
|
325 |
+
*/
|
326 |
+
protected function _cleanUpImages($entries,$table)
|
327 |
+
{
|
328 |
+
$toDelete = array();
|
329 |
+
foreach ($entries as $entry) {
|
330 |
+
$file = Mage::getBaseDir() . DS . $entry['path'] . DS . $entry['image_name'];
|
331 |
+
if (!is_file($file)) {
|
332 |
+
$toDelete[] = $entry['id'];
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
if (count($toDelete) > 0) {
|
337 |
+
$toDeleteString = implode(',',$toDelete);
|
338 |
+
$resource = Mage::getSingleton('core/resource');
|
339 |
+
$writeConnection = $resource->getConnection('core_write');
|
340 |
+
|
341 |
+
$query = "DELETE FROM {$table} WHERE id IN ({$toDeleteString})";
|
342 |
+
|
343 |
+
$writeConnection->query($query);
|
344 |
+
}
|
345 |
}
|
346 |
}
|
app/code/local/Welance/Kraken/controllers/KrakenController.php
CHANGED
@@ -26,7 +26,10 @@ class Welance_Kraken_KrakenController extends Mage_Adminhtml_Controller_Action
|
|
26 |
|
27 |
public function indexAction()
|
28 |
{
|
29 |
-
Mage::helper('welance_kraken')
|
|
|
|
|
|
|
30 |
|
31 |
$this->loadLayout();
|
32 |
$this->renderLayout();
|
26 |
|
27 |
public function indexAction()
|
28 |
{
|
29 |
+
$helper = Mage::helper('welance_kraken');
|
30 |
+
$helper->deletePendingEntries();
|
31 |
+
$helper->removeDeletedImagesFromDatabase();
|
32 |
+
|
33 |
|
34 |
$this->loadLayout();
|
35 |
$this->renderLayout();
|
app/design/adminhtml/default/default/template/kraken/images/media.phtml
CHANGED
@@ -10,6 +10,18 @@
|
|
10 |
$imagesJson = $this->getNewImagesAsJson();
|
11 |
$total = count(json_decode($imagesJson));
|
12 |
$toBeOptimized = $folderImagesCount - $imagesCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
?>
|
14 |
|
15 |
<h3>Media Images</h3>
|
10 |
$imagesJson = $this->getNewImagesAsJson();
|
11 |
$total = count(json_decode($imagesJson));
|
12 |
$toBeOptimized = $folderImagesCount - $imagesCount;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* quickfix for deleted images, if we have more images in DB then on disk
|
16 |
+
* this should not happen anymore due to the new function
|
17 |
+
* Welance_Kraken_Helper_Data::removeDeletedImagesFromDatabase
|
18 |
+
* But just to be sure, I added this
|
19 |
+
*/
|
20 |
+
if($toBeOptimized < 0) {
|
21 |
+
$percent = 100;
|
22 |
+
$toBeOptimized = 0;
|
23 |
+
$imagesCount = $folderImagesCount;
|
24 |
+
}
|
25 |
?>
|
26 |
|
27 |
<h3>Media Images</h3>
|
app/design/adminhtml/default/default/template/kraken/images/skin.phtml
CHANGED
@@ -10,6 +10,18 @@
|
|
10 |
$imagesJson = $this->getNewImagesAsJson();
|
11 |
$total = count(json_decode($imagesJson));
|
12 |
$toBeOptimized = $folderImagesCount - $imagesCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
?>
|
14 |
|
15 |
<h3>Skin Images</h3>
|
10 |
$imagesJson = $this->getNewImagesAsJson();
|
11 |
$total = count(json_decode($imagesJson));
|
12 |
$toBeOptimized = $folderImagesCount - $imagesCount;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* quickfix for deleted images, if we have more images in DB then on disk
|
16 |
+
* this should not happen anymore due to the new function
|
17 |
+
* Welance_Kraken_Helper_Data::removeDeletedImagesFromDatabase
|
18 |
+
* But just to be sure, I added this
|
19 |
+
*/
|
20 |
+
if($toBeOptimized < 0) {
|
21 |
+
$percent = 100;
|
22 |
+
$toBeOptimized = 0;
|
23 |
+
$imagesCount = $folderImagesCount;
|
24 |
+
}
|
25 |
?>
|
26 |
|
27 |
<h3>Skin Images</h3>
|
app/design/frontend/base/default/layout/kraken.xml
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
|
3 |
-
<layout>
|
4 |
-
<catalog_product_view>
|
5 |
-
<reference name="head">
|
6 |
-
<action method="addJs"><script>kraken/async.js</script></action>
|
7 |
-
<action method="addJs"><script>kraken/optimize.v2.min.js</script></action>
|
8 |
-
</reference>
|
9 |
-
<reference name="before_body_end">
|
10 |
-
<block type="welance_kraken/product_image" name="welance.kraken.cache.optimizer" as="cacheOptimizer" template="kraken/product/image.phtml" />
|
11 |
-
</reference>
|
12 |
-
</catalog_product_view>
|
13 |
-
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/kraken/product/image.phtml
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
<script type="text/javascript">
|
2 |
-
var cacheImages = <?php echo $this->getImagesToOptimize(); ?>;
|
3 |
-
var requestUrl = '<?php echo Mage::getUrl('kraken/optimize/cache') ?>';
|
4 |
-
var cacheConcurrency = <?php echo $this->getConcurrency() ?>;
|
5 |
-
|
6 |
-
document.observe("dom:loaded", function() {
|
7 |
-
optimizeImages.optimizeCache(cacheImages);
|
8 |
-
});
|
9 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/kraken/optimize.js
CHANGED
@@ -112,9 +112,9 @@
|
|
112 |
var successMessage = "";
|
113 |
|
114 |
if (type === "media") {
|
115 |
-
successMessage = "Congratulations! Your skin images have been optimized.";
|
116 |
-
} else {
|
117 |
successMessage = "Congratulations! Your media images have been optimized.";
|
|
|
|
|
118 |
}
|
119 |
|
120 |
$j("#kraken-modal-head").text(successMessage);
|
112 |
var successMessage = "";
|
113 |
|
114 |
if (type === "media") {
|
|
|
|
|
115 |
successMessage = "Congratulations! Your media images have been optimized.";
|
116 |
+
} else {
|
117 |
+
successMessage = "Congratulations! Your skin images have been optimized.";
|
118 |
}
|
119 |
|
120 |
$j("#kraken-modal-head").text(successMessage);
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Kraken_Image_Optimizer</name>
|
4 |
-
<version>2.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/GPL-3.0">GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>This extension enables Magento users to optimize their product, skin and media images by consuming the Kraken.io image optimization API. (https://kraken.io)</summary>
|
10 |
<description>This extension exists for the sole purpose of allowing Magento users to optimize their product, skin and media images by consuming the Kraken.io image optimization API. (https://kraken.io)</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>Nekkra UG</name><user>KrakenIO</user><email>support@kraken.io</email></author></authors>
|
13 |
-
<date>2016-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir name="Welance"><dir name="Kraken"><dir name="Block"><dir name="Adminhtml"><dir name="Api"><file name="Signup.php" hash="56a9ee65c5d9fd769b7a5a0854b71a16"/><file name="Status.php" hash="99dd2cb6da9d62e4d8cab36ea29d13e5"/><dir name="User"><file name="Status.php" hash="f33827a151d7ccd76684dde79599c3a2"/></dir></dir><dir name="Images"><file name="Media.php" hash="9dd94a375ceaa004df26d314a935fa63"/><file name="Skin.php" hash="f0dc5623a3974e50ce94b71cae4cd7cd"/></dir><file name="Images.php" hash="77fe1a1c7a0fb28209a741266467db69"/><file name="Statistics.php" hash="6cdae1bc41185b93c49d97465ee75704"/></dir><dir name="Product"><file name="Image.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Kraken_Image_Optimizer</name>
|
4 |
+
<version>2.0.6</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/GPL-3.0">GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>This extension enables Magento users to optimize their product, skin and media images by consuming the Kraken.io image optimization API. (https://kraken.io)</summary>
|
10 |
<description>This extension exists for the sole purpose of allowing Magento users to optimize their product, skin and media images by consuming the Kraken.io image optimization API. (https://kraken.io)</description>
|
11 |
+
<notes>Stability improvements</notes>
|
12 |
<authors><author><name>Nekkra UG</name><user>KrakenIO</user><email>support@kraken.io</email></author></authors>
|
13 |
+
<date>2016-03-21</date>
|
14 |
+
<time>19:20:07</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Welance"><dir name="Kraken"><dir name="Block"><dir name="Adminhtml"><dir name="Api"><file name="Signup.php" hash="56a9ee65c5d9fd769b7a5a0854b71a16"/><file name="Status.php" hash="99dd2cb6da9d62e4d8cab36ea29d13e5"/><dir name="User"><file name="Status.php" hash="f33827a151d7ccd76684dde79599c3a2"/></dir></dir><dir name="Images"><file name="Media.php" hash="9dd94a375ceaa004df26d314a935fa63"/><file name="Skin.php" hash="f0dc5623a3974e50ce94b71cae4cd7cd"/></dir><file name="Images.php" hash="77fe1a1c7a0fb28209a741266467db69"/><file name="Statistics.php" hash="6cdae1bc41185b93c49d97465ee75704"/></dir><dir name="Product"><file name="Image.php" hash="d007993838d4729e7fb0d31b6a7245eb"/></dir></dir><dir name="Helper"><file name="Api.php" hash="ae1d48033696885f328d198f5b6deeb9"/><file name="Data.php" hash="28d4d9ba0359414b8153e15298f922a9"/></dir><dir name="Model"><file name="Abstract.php" hash="46ad69f601aa392e44fadf43dc8ff558"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Validation"><file name="File.php" hash="03b116c93529a00f064c428519415b90"/><file name="Quality.php" hash="63919067f4576cc1a0c6ef663b1d1779"/></dir></dir><dir name="Source"><file name="Compression.php" hash="516d83f51e2216b45e51d20d6d1f8575"/><file name="Concurrency.php" hash="436d106916fae3d01bd7272e34d9771c"/></dir></dir></dir></dir><dir name="Image"><file name="Cache.php" hash="b1405ed2975e5b2fa0136f7722f03828"/></dir><dir name="Images"><file name="Media.php" hash="3d73a5ba9276744d92de042f4ca5d228"/><file name="Skin.php" hash="d6181c6772baa9a84d26e6adda5c87be"/></dir><file name="Observer.php" hash="8e27670e4c5ce3d62d0fcc5b27b6972a"/><dir name="Product"><file name="Image.php" hash="11c24a47125de4787bf082a2227c1e77"/></dir><dir name="Resource"><dir name="Image"><dir name="Cache"><file name="Collection.php" hash="4f29016539f9586ba707c1815f1e12b6"/></dir><file name="Cache.php" hash="7058d029a436aa3d0be1dc6f3c7fae57"/></dir><dir name="Images"><dir name="Media"><file name="Collection.php" hash="e77abb3c2122a0f5582bf14739935d85"/></dir><file name="Media.php" hash="c6aa05e4362b645b001854e9578ee5d1"/><dir name="Skin"><file name="Collection.php" hash="2e81919a1fa3014a9083b12382fc46e0"/></dir><file name="Skin.php" hash="420d0b85798bbd5eb52d40d96eff2868"/></dir></dir></dir><dir name="controllers"><file name="KrakenController.php" hash="424db7935fd2b3d47a3aae01a3947bb9"/><file name="OptimizeController.php" hash="d4a7b8d09b951960c6afd93ea4a3bda9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="71d3f77d2a29e267a1b3b172ac457ccc"/><file name="config.xml" hash="7689401c8f2325863682ff2e51072a15"/><file name="system.xml" hash="083bab919a0a16a8ab546815d7526850"/></dir><dir name="sql"><dir name="welance_kraken_setup"><file name="mysql4-install-0.0.1.php" hash="c672010d8288677aea0d008a4ec49d0f"/><file name="mysql4-upgrade-0.0.1-0.0.2.php" hash="f6ec9a39c730faa436d29338b35a21b2"/><file name="mysql4-upgrade-0.0.2-0.0.3.php" hash="884f018b06073d09cd38094251316a12"/><file name="mysql4-upgrade-0.0.3-0.0.4.php" hash="21b4fed490c176909fc54d36f49b6caa"/><file name="mysql4-upgrade-0.0.4-0.0.5.php" hash="3399d922082321a9c9fdb3f4d8ddbbb0"/><file name="mysql4-upgrade-0.0.5-0.0.6.php" hash="8084b2f3b1fe2bad7bbbbd1136974289"/><file name="mysql4-upgrade-0.0.6-2.0.0.php" hash="a62483557a3d026e7c2b57999f8924a4"/><file name="mysql4-upgrade-1.0.0-2.0.0.php" hash="a62483557a3d026e7c2b57999f8924a4"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="kraken.xml" hash="a2533032af5ce2b9aa1e5506a213faf9"/></dir><dir name="template"><dir name="kraken"><dir name="images"><file name="media.phtml" hash="9193eeefedcbc34936d1e21c228d7646"/><file name="skin.phtml" hash="40e111e74babb31943587beb646e5554"/></dir><file name="images.phtml" hash="f4a3760c6340e2a83569a715975c0a88"/><file name="statistics.phtml" hash="ecc8b4f9c46580bbe57e7dbfdae637e5"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Welance_Kraken.xml" hash="5924028abd4db847049907d0685fe928"/></dir></target><target name="mageweb"><dir name="js"><dir name="kraken"><file name="async.js" hash="69a9fc4244b4ed9465d9dc17bfec7e8e"/><file name="jquery.js" hash="895323ed2f7258af4fae2c738c8aea49"/><file name="optimize.js" hash="3ce6d764f29af8dace394d644dedb75e"/><file name="optimize.v2.min.js" hash="00fe66aea8cef84efcc1a587e6471329"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="kraken"><file name="images.css" hash="4efcb99215e85cea9ef8904594b35d06"/><file name="kraken-tile.png" hash="dca7a9d6784bf34d32d71560f1744fae"/></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
skin/adminhtml/default/default/kraken/kraken-tile.png
CHANGED
Binary file
|