diff --git a/.htaccess b/.htaccess
index 074758ad18f..3fec686913b 100644
--- a/.htaccess
+++ b/.htaccess
@@ -216,6 +216,7 @@
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresActive On
+ ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php
index 8356e6b3de6..a455e07e78b 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php
@@ -54,7 +54,7 @@ protected function _prepareLayout()
$browseConfig = $this->getUploader()->getButtonConfig();
$browseConfig
->setAttributes([
- 'accept' => $browseConfig->getMimeTypesByExtensions('gif, png, jpeg, jpg')
+ 'accept' => $browseConfig->getMimeTypesByExtensions(Varien_Io_File::ALLOWED_IMAGES_EXTENSIONS)
]);
Mage::dispatchEvent('catalog_product_gallery_prepare_layout', ['block' => $this]);
diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Image.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Image.php
index 460d3859e75..7ccff7662a7 100644
--- a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Image.php
+++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Image.php
@@ -27,7 +27,7 @@ class Mage_Adminhtml_Model_System_Config_Backend_Image extends Mage_Adminhtml_Mo
*/
protected function _getAllowedExtensions()
{
- return ['jpg', 'jpeg', 'gif', 'png'];
+ return Varien_Io_File::ALLOWED_IMAGES_EXTENSIONS;
}
/**
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
index 524a430a3b7..c7562494c90 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
@@ -31,7 +31,7 @@ public function uploadAction()
{
try {
$uploader = new Mage_Core_Model_File_Uploader('image');
- $uploader->setAllowedExtensions(['jpg','jpeg','gif','png']);
+ $uploader->setAllowedExtensions(Varien_Io_File::ALLOWED_IMAGES_EXTENSIONS);
$uploader->addValidateCallback(
'catalog_product_image',
Mage::helper('catalog/image'),
diff --git a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
index fe50f6b01f8..bfa760c01ac 100644
--- a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
@@ -808,6 +808,9 @@ public function viewfileAction()
case 'jpg':
$contentType = 'image/jpeg';
break;
+ case 'webp':
+ $contentType = 'image/webp';
+ break;
case 'png':
$contentType = 'image/png';
break;
diff --git a/app/code/core/Mage/Catalog/Model/Api2/Product/Image/Rest.php b/app/code/core/Mage/Catalog/Model/Api2/Product/Image/Rest.php
index 5423cca892d..3af1c678ac1 100644
--- a/app/code/core/Mage/Catalog/Model/Api2/Product/Image/Rest.php
+++ b/app/code/core/Mage/Catalog/Model/Api2/Product/Image/Rest.php
@@ -32,6 +32,7 @@ abstract class Mage_Catalog_Model_Api2_Product_Image_Rest extends Mage_Catalog_M
* @var array
*/
protected $_mimeTypes = [
+ 'image/webp' => 'webp',
'image/jpg' => 'jpg',
'image/jpeg' => 'jpg',
'image/gif' => 'gif',
diff --git a/app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php b/app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php
index 577c0598f46..4c0e34c3709 100644
--- a/app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php
+++ b/app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php
@@ -22,41 +22,51 @@
class Mage_Catalog_Model_Category_Attribute_Backend_Image extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
{
/**
- * Save uploaded file and set its name to category
+ * @return array
+ */
+ public function getAllowedExtensions(): array
+ {
+ return Varien_Io_File::ALLOWED_IMAGES_EXTENSIONS;
+ }
+
+ /**
+ * Save uploaded file and set its name to category attribute
* @param Varien_Object $object
* @return $this
*/
public function afterSave($object)
{
- $value = $object->getData($this->getAttribute()->getName());
- if (empty($value) && empty($_FILES)) {
- return $this;
- }
+ $name = $this->getAttribute()->getName();
+ $value = $object->getData($name);
if (is_array($value) && !empty($value['delete'])) {
- $object->setData($this->getAttribute()->getName(), '');
- $this->getAttribute()->getEntity()
- ->saveAttribute($object, $this->getAttribute()->getName());
+ $object->setData($name, '');
+ $this->getAttribute()->getEntity()->saveAttribute($object, $name);
return $this;
}
- $path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
+ if (!empty($_FILES[$name])) {
+ try {
+ $validator = Mage::getModel('core/file_validator_image');
+ $uploader = Mage::getModel('core/file_uploader', $name);
+ $uploader->setAllowedExtensions($this->getAllowedExtensions());
+ $uploader->setAllowRenameFiles(true);
+ $uploader->setFilesDispersion(false);
+ $uploader->addValidateCallback(Mage_Core_Model_File_Validator_Image::NAME, $validator, 'validate');
+ $uploader->save(Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category');
- try {
- $validator = Mage::getModel('core/file_validator_image');
- $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
- $uploader->setAllowedExtensions(['jpg','jpeg','gif','png']);
- $uploader->setAllowRenameFiles(true);
- $uploader->addValidateCallback(Mage_Core_Model_File_Validator_Image::NAME, $validator, 'validate');
- $result = $uploader->save($path);
-
- $object->setData($this->getAttribute()->getName(), $result['file']);
- $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
- } catch (Exception $e) {
- if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
- Mage::logException($e);
+ $fileName = $uploader->getUploadedFileName();
+ if ($fileName) {
+ $object->setData($name, $fileName);
+ $this->getAttribute()->getEntity()->saveAttribute($object, $name);
+ }
+ } catch (Exception $e) {
+ if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
+ Mage::logException($e);
+ }
}
}
+
return $this;
}
}
diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
index 8ee2ab0b3ab..600be73a4b9 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
@@ -288,8 +288,7 @@ public function addImage(
Mage::dispatchEvent('catalog_product_media_add_image', ['product' => $product, 'image' => $file]);
$pathinfo = pathinfo($file);
- $imgExtensions = ['jpg','jpeg','gif','png'];
- if (!isset($pathinfo['extension']) || !in_array(strtolower($pathinfo['extension']), $imgExtensions)) {
+ if (!isset($pathinfo['extension']) || !in_array(strtolower($pathinfo['extension']), Varien_Io_File::ALLOWED_IMAGES_EXTENSIONS)) {
Mage::throwException(Mage::helper('catalog')->__('Invalid image file type.'));
}
diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api.php
index 3eaab04b6ef..42a081df297 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api.php
@@ -33,6 +33,7 @@ class Mage_Catalog_Model_Product_Attribute_Media_Api extends Mage_Catalog_Model_
* @var array
*/
protected $_mimeTypes = [
+ 'image/webp' => 'webp',
'image/jpeg' => 'jpg',
'image/gif' => 'gif',
'image/png' => 'png'
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Image.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Image.php
index 3a3005e4fc3..71499311394 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Image.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Attribute/Backend/Image.php
@@ -22,37 +22,49 @@
class Mage_Catalog_Model_Resource_Product_Attribute_Backend_Image extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
{
/**
+ * @return array
+ */
+ public function getAllowedExtensions(): array
+ {
+ return Varien_Io_File::ALLOWED_IMAGES_EXTENSIONS;
+ }
+
+ /**
+ * Save uploaded file and set its name to product attribute
* @param Varien_Object $object
* @return $this
*/
public function afterSave($object)
{
- $value = $object->getData($this->getAttribute()->getName());
+ $name = $this->getAttribute()->getName();
+ $value = $object->getData($name);
if (is_array($value) && !empty($value['delete'])) {
- $object->setData($this->getAttribute()->getName(), '');
- $this->getAttribute()->getEntity()
- ->saveAttribute($object, $this->getAttribute()->getName());
+ $object->setData($name, '');
+ $this->getAttribute()->getEntity()->saveAttribute($object, $name);
return $this;
}
- try {
- $validator = Mage::getModel('core/file_validator_image');
- $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
- $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);
- $uploader->setAllowRenameFiles(true);
- $uploader->setFilesDispersion(true);
- $uploader->addValidateCallback(Mage_Core_Model_File_Validator_Image::NAME, $validator, 'validate');
- $uploader->save(Mage::getBaseDir('media') . '/catalog/product');
+ if (!empty($_FILES[$name])) {
+ try {
+ $validator = Mage::getModel('core/file_validator_image');
+ $uploader = Mage::getModel('core/file_uploader', $name);
+ $uploader->setAllowedExtensions($this->getAllowedExtensions());
+ $uploader->setAllowRenameFiles(true);
+ $uploader->setFilesDispersion(true);
+ $uploader->addValidateCallback(Mage_Core_Model_File_Validator_Image::NAME, $validator, 'validate');
+ $uploader->save(Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product');
- $fileName = $uploader->getUploadedFileName();
- if ($fileName) {
- $object->setData($this->getAttribute()->getName(), $fileName);
- $this->getAttribute()->getEntity()
- ->saveAttribute($object, $this->getAttribute()->getName());
+ $fileName = $uploader->getUploadedFileName();
+ if ($fileName) {
+ $object->setData($name, $fileName);
+ $this->getAttribute()->getEntity()->saveAttribute($object, $name);
+ }
+ } catch (Exception $e) {
+ if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
+ Mage::logException($e);
+ }
}
- } catch (Exception $e) {
- return $this;
}
return $this;
diff --git a/app/code/core/Mage/Cms/etc/config.xml b/app/code/core/Mage/Cms/etc/config.xml
index 78f46c3e46c..d80e0040caf 100644
--- a/app/code/core/Mage/Cms/etc/config.xml
+++ b/app/code/core/Mage/Cms/etc/config.xml
@@ -102,12 +102,14 @@
1
1
1
+ 1
1
1
1
1
+ 1
1
diff --git a/app/code/core/Mage/Core/Model/File/Validator/Image.php b/app/code/core/Mage/Core/Model/File/Validator/Image.php
index 9b0d6acd210..1a7e6658e2a 100644
--- a/app/code/core/Mage/Core/Model/File/Validator/Image.php
+++ b/app/code/core/Mage/Core/Model/File/Validator/Image.php
@@ -24,6 +24,7 @@ class Mage_Core_Model_File_Validator_Image
public const NAME = "isImage";
protected $_allowedImageTypes = [
+ IMAGETYPE_WEBP,
IMAGETYPE_JPEG,
IMAGETYPE_GIF,
IMAGETYPE_JPEG2000,
@@ -42,6 +43,7 @@ class Mage_Core_Model_File_Validator_Image
public function setAllowedImageTypes(array $imageFileExtensions = [])
{
$map = [
+ 'webp' => [IMAGETYPE_WEBP],
'tif' => [IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM],
'tiff' => [IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM],
'jpg' => [IMAGETYPE_JPEG, IMAGETYPE_JPEG2000],
@@ -121,6 +123,9 @@ public function validate($filePath)
case IMAGETYPE_JPEG:
imagejpeg($img, $filePath, $imageQuality);
break;
+ case IMAGETYPE_WEBP:
+ imagewebp($img, $filePath, $imageQuality);
+ break;
case IMAGETYPE_PNG:
imagepng($img, $filePath);
break;
diff --git a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php b/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php
index 31de8eb27c8..cfa8ea78124 100644
--- a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php
+++ b/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php
@@ -227,7 +227,7 @@ public function getLinkData()
*/
public function getPriceValue($value)
{
- return number_format($value, 2, null, '');
+ return number_format($value ?? 0, 2, null, '');
}
/**
diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Image.php b/app/code/core/Mage/Eav/Model/Attribute/Data/Image.php
index 98829283255..8d5fbe1f43a 100644
--- a/app/code/core/Mage/Eav/Model/Attribute/Data/Image.php
+++ b/app/code/core/Mage/Eav/Model/Attribute/Data/Image.php
@@ -47,6 +47,7 @@ protected function _validateByRules($value)
1 => 'gif',
2 => 'jpg',
3 => 'png',
+ 18 => 'webp'
];
if (!isset($allowImageTypes[$imageProp[2]])) {
diff --git a/app/code/core/Mage/ImportExport/Model/Import/Uploader.php b/app/code/core/Mage/ImportExport/Model/Import/Uploader.php
index 5304f508d4c..f5720ee6e37 100644
--- a/app/code/core/Mage/ImportExport/Model/Import/Uploader.php
+++ b/app/code/core/Mage/ImportExport/Model/Import/Uploader.php
@@ -24,6 +24,7 @@ class Mage_ImportExport_Model_Import_Uploader extends Mage_Core_Model_File_Uploa
protected $_tmpDir = '';
protected $_destDir = '';
protected $_allowedMimeTypes = [
+ 'webp' => 'image/webp',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
diff --git a/app/code/core/Mage/Media/Model/File/Image.php b/app/code/core/Mage/Media/Model/File/Image.php
index e913a93a68b..0e36833a97a 100644
--- a/app/code/core/Mage/Media/Model/File/Image.php
+++ b/app/code/core/Mage/Media/Model/File/Image.php
@@ -92,6 +92,10 @@ public function getImage(Mage_Media_Model_Image $object)
$resource = imagecreatefromjpeg($object->getFilePath());
break;
+ case 'webp':
+ $resource = imagecreatefromwebp($object->getFilePath());
+ break;
+
case 'gif':
$resource = imagecreatefromgif($object->getFilePath());
break;
@@ -176,6 +180,9 @@ public function saveAs(Mage_Media_Model_Image $object, $extension = null)
case 'jpeg':
$result = imagejpeg($object->getTmpImage(), $object->getFilePath(true), 80);
break;
+ case 'webp':
+ $result = imagewebp($object->getTmpImage(), $object->getFilePath(true), 80);
+ break;
case 'gif':
$result = imagegif($object->getTmpImage(), $object->getFilePath(true));
break;
diff --git a/app/code/core/Mage/SalesRule/Model/Validator.php b/app/code/core/Mage/SalesRule/Model/Validator.php
index 8300c9e7cf0..dfec594d192 100644
--- a/app/code/core/Mage/SalesRule/Model/Validator.php
+++ b/app/code/core/Mage/SalesRule/Model/Validator.php
@@ -465,10 +465,10 @@ public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
$discountAmount = $result->getDiscountAmount();
$baseDiscountAmount = $result->getBaseDiscountAmount();
- $percentKey = $item->getDiscountPercent();
/**
* Process "delta" rounding
*/
+ $percentKey = (string) $item->getDiscountPercent();
if ($percentKey) {
$delta = $this->_roundingDeltas[$percentKey] ?? 0;
$baseDelta = $this->_baseRoundingDeltas[$percentKey] ?? 0;
diff --git a/app/code/core/Mage/Uploader/Helper/File.php b/app/code/core/Mage/Uploader/Helper/File.php
index 236adfbedb6..cd4dc9090f6 100644
--- a/app/code/core/Mage/Uploader/Helper/File.php
+++ b/app/code/core/Mage/Uploader/Helper/File.php
@@ -235,6 +235,7 @@ class Mage_Uploader_Helper_File extends Mage_Core_Helper_Abstract
'xjisp' => 'application/vnd.jisp',
'xjlt' => 'application/vnd.hp-jlyt',
'xjoda' => 'application/vnd.joost.joda-archive',
+ 'xwebp' => 'image/webp',
'xjpe' => 'image/jpeg',
'xjpeg' => 'image/jpeg',
'xjpg' => 'image/jpeg',
diff --git a/composer.lock b/composer.lock
index e9ff8918641..f70e897a351 100644
--- a/composer.lock
+++ b/composer.lock
@@ -2664,16 +2664,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
- "version": "v3.21.0",
+ "version": "v3.22.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
- "reference": "f29a0598c022baf99d2136da533820fec63167ed"
+ "reference": "92b019f6c8d79aa26349d0db7671d37440dc0ff3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/f29a0598c022baf99d2136da533820fec63167ed",
- "reference": "f29a0598c022baf99d2136da533820fec63167ed",
+ "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/92b019f6c8d79aa26349d0db7671d37440dc0ff3",
+ "reference": "92b019f6c8d79aa26349d0db7671d37440dc0ff3",
"shasum": ""
},
"require": {
@@ -2697,6 +2697,7 @@
"symfony/stopwatch": "^5.4 || ^6.0"
},
"require-dev": {
+ "facile-it/paraunit": "^1.3 || ^2.0",
"justinrainbow/json-schema": "^5.2",
"keradus/cli-executor": "^2.0",
"mikey179/vfsstream": "^1.6.11",
@@ -2748,7 +2749,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
- "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.21.0"
+ "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.22.0"
},
"funding": [
{
@@ -2756,7 +2757,7 @@
"type": "github"
}
],
- "time": "2023-07-05T21:28:10+00:00"
+ "time": "2023-07-16T23:08:06+00:00"
},
{
"name": "macopedia/phpstan-magento1",
@@ -2895,16 +2896,16 @@
},
{
"name": "nikic/php-parser",
- "version": "v4.15.5",
+ "version": "v4.16.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e"
+ "reference": "19526a33fb561ef417e822e85f08a00db4059c17"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/11e2663a5bc9db5d714eedb4277ee300403b4a9e",
- "reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17",
+ "reference": "19526a33fb561ef417e822e85f08a00db4059c17",
"shasum": ""
},
"require": {
@@ -2945,9 +2946,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.5"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0"
},
- "time": "2023-05-19T20:20:00+00:00"
+ "time": "2023-06-25T14:52:30+00:00"
},
{
"name": "openmage/dev-copyright",
@@ -3752,16 +3753,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "9.6.9",
+ "version": "9.6.10",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "a9aceaf20a682aeacf28d582654a1670d8826778"
+ "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a9aceaf20a682aeacf28d582654a1670d8826778",
- "reference": "a9aceaf20a682aeacf28d582654a1670d8826778",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a6d351645c3fe5a30f5e86be6577d946af65a328",
+ "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328",
"shasum": ""
},
"require": {
@@ -3835,7 +3836,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.9"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.10"
},
"funding": [
{
@@ -3851,7 +3852,7 @@
"type": "tidelift"
}
],
- "time": "2023-06-11T06:13:56+00:00"
+ "time": "2023-07-10T04:04:23+00:00"
},
{
"name": "psr/cache",
diff --git a/lib/Varien/File/Transfer/Adapter/Http.php b/lib/Varien/File/Transfer/Adapter/Http.php
index 202ec37f101..f7d424c46f0 100644
--- a/lib/Varien/File/Transfer/Adapter/Http.php
+++ b/lib/Varien/File/Transfer/Adapter/Http.php
@@ -32,6 +32,7 @@ class Varien_File_Transfer_Adapter_Http
'flv' => 'video/x-flv',
// images
+ 'webp' => 'image/webp',
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
diff --git a/lib/Varien/Image/Adapter/Gd2.php b/lib/Varien/Image/Adapter/Gd2.php
index 86315faccef..2776380bc56 100644
--- a/lib/Varien/Image/Adapter/Gd2.php
+++ b/lib/Varien/Image/Adapter/Gd2.php
@@ -17,6 +17,7 @@ class Varien_Image_Adapter_Gd2 extends Varien_Image_Adapter_Abstract
{
protected $_requiredExtensions = ["gd"];
private static $_callbacks = [
+ IMAGETYPE_WEBP => ['output' => 'imagewebp', 'create' => 'imagecreatefromwebp'],
IMAGETYPE_GIF => ['output' => 'imagegif', 'create' => 'imagecreatefromgif'],
IMAGETYPE_JPEG => ['output' => 'imagejpeg', 'create' => 'imagecreatefromjpeg'],
IMAGETYPE_PNG => ['output' => 'imagepng', 'create' => 'imagecreatefrompng'],
@@ -150,6 +151,11 @@ public function save($destination = null, $newName = null)
}
}
+ // convert palette based image to true color
+ if ($this->_fileType == IMAGETYPE_WEBP) {
+ imagepalettetotruecolor($this->_imageHandler);
+ }
+
if (!$this->_resized) {
// keep alpha transparency
$isAlpha = false;
diff --git a/lib/Varien/Io/File.php b/lib/Varien/Io/File.php
index 47ca72c8570..d583d7287e8 100644
--- a/lib/Varien/Io/File.php
+++ b/lib/Varien/Io/File.php
@@ -91,6 +91,11 @@ class Varien_Io_File extends Varien_Io_Abstract
*/
protected $_streamException;
+ /**
+ * @var string[]
+ */
+ public const ALLOWED_IMAGES_EXTENSIONS = ['webp', 'jpg', 'jpeg', 'png', 'gif', 'bmp'];
+
public function __construct()
{
// Initialize shutdown function
@@ -819,7 +824,7 @@ public function ls($grep = null)
$list_item['size'] = filesize($fullpath);
$list_item['leaf'] = true;
if (isset($pathinfo['extension'])
- && in_array(strtolower($pathinfo['extension']), ['jpg', 'jpeg', 'gif', 'bmp', 'png'])
+ && in_array(strtolower($pathinfo['extension']), self::ALLOWED_IMAGES_EXTENSIONS)
&& $list_item['size'] > 0
) {
$list_item['is_image'] = true;