|
9 | 9 | use Magento\Framework\Exception\FileSystemException; |
10 | 10 | use Magento\Framework\Image\Adapter\AbstractAdapter; |
11 | 11 | use Magento\Framework\Phrase; |
| 12 | +use MagestyApps\WebImages\Helper\ImageHelper; |
12 | 13 |
|
13 | 14 | /** |
14 | 15 | * Gd2 adapter. |
@@ -50,6 +51,28 @@ class Gd2 extends AbstractAdapter |
50 | 51 | */ |
51 | 52 | protected $_resized = false; |
52 | 53 |
|
| 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 | + |
53 | 76 | /** |
54 | 77 | * For properties reset, e.g. mimeType caching. |
55 | 78 | * |
@@ -109,6 +132,22 @@ private function validateURLScheme(string $filename) : bool |
109 | 132 | return true; |
110 | 133 | } |
111 | 134 |
|
| 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 | + |
112 | 151 | /** |
113 | 152 | * Checks whether memory limit is reached. |
114 | 153 | * |
|
0 commit comments