Skip to content

Commit f3e93fc

Browse files
author
Alexander Tolochko
committed
Fix uploading SVG images for option swatches
1 parent 48cb419 commit f3e93fc

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Model/Image/Adapter/Gd2.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Exception\FileSystemException;
1010
use Magento\Framework\Image\Adapter\AbstractAdapter;
1111
use Magento\Framework\Phrase;
12+
use MagestyApps\WebImages\Helper\ImageHelper;
1213

1314
/**
1415
* Gd2 adapter.
@@ -50,6 +51,28 @@ class Gd2 extends AbstractAdapter
5051
*/
5152
protected $_resized = false;
5253

54+
/**
55+
* @var ImageHelper
56+
*/
57+
private $helper;
58+
59+
/**
60+
* @param \Magento\Framework\Filesystem $filesystem
61+
* @param \Psr\Log\LoggerInterface $logger
62+
* @param ImageHelper $helper
63+
* @param array $data
64+
*/
65+
public function __construct(
66+
\Magento\Framework\Filesystem $filesystem,
67+
\Psr\Log\LoggerInterface $logger,
68+
ImageHelper $helper,
69+
array $data = []
70+
) {
71+
parent::__construct($filesystem, $logger, $data);
72+
73+
$this->helper = $helper;
74+
}
75+
5376
/**
5477
* For properties reset, e.g. mimeType caching.
5578
*
@@ -109,6 +132,22 @@ private function validateURLScheme(string $filename) : bool
109132
return true;
110133
}
111134

135+
/**
136+
* @param string $filePath
137+
* @return bool
138+
*/
139+
public function validateUploadFile($filePath)
140+
{
141+
/*
142+
* FIX: Skip validation for vector images
143+
*/
144+
if ($this->helper->isVectorImage($filePath)) {
145+
return file_exists($filePath);
146+
}
147+
148+
return parent::validateUploadFile($filePath);
149+
}
150+
112151
/**
113152
* Checks whether memory limit is reached.
114153
*

0 commit comments

Comments
 (0)