|
12 | 12 | use Magento\Framework\App\Config\ScopeConfigInterface;
|
13 | 13 | use Magento\Framework\App\Filesystem\DirectoryList;
|
14 | 14 | use Magento\Framework\App\ObjectManager;
|
| 15 | +use Magento\Framework\Data\Collection; |
15 | 16 | use Magento\Framework\Exception\LocalizedException;
|
16 | 17 |
|
17 | 18 | /**
|
@@ -289,6 +290,7 @@ protected function createSubDirectories($path)
|
289 | 290 | *
|
290 | 291 | * @return array
|
291 | 292 | * @deprecated
|
| 293 | + * @see isDirectoryAllowed |
292 | 294 | */
|
293 | 295 | protected function getConditionsForExcludeDirs()
|
294 | 296 | {
|
@@ -317,6 +319,7 @@ protected function getConditionsForExcludeDirs()
|
317 | 319 | * @param array $conditions
|
318 | 320 | * @return \Magento\Framework\Data\Collection\Filesystem
|
319 | 321 | * @deprecated
|
| 322 | + * @see \Magento\Framework\Data\Collection\Filesystem::setDirsFilter |
320 | 323 | */
|
321 | 324 | protected function removeItemFromCollection($collection, $conditions)
|
322 | 325 | {
|
@@ -415,7 +418,7 @@ public function getFilesCollection($path, $type = null)
|
415 | 418 | $mimeType = $itemStats['mimetype'] ?? $this->mime->getMimeType($item->getFilename());
|
416 | 419 | $item->setMimeType($mimeType);
|
417 | 420 |
|
418 |
| - if ($this->isImage($item->getBasename()) && $item->getSize() > 0) { |
| 421 | + if ($this->isImageValid($item)) { |
419 | 422 | $thumbUrl = $this->getThumbnailUrl($item->getFilename(), true);
|
420 | 423 | // generate thumbnail "on the fly" if it does not exists
|
421 | 424 | if (!$thumbUrl) {
|
@@ -1064,4 +1067,15 @@ private function getAllowedDirMask(string $path)
|
1064 | 1067 |
|
1065 | 1068 | return '/^(' . implode('|', array_unique(array_column($allowedDirs, $subfolderLevel - 1))) . ')$/';
|
1066 | 1069 | }
|
| 1070 | + |
| 1071 | + /** |
| 1072 | + * Checks if the file is an image and has a size greater than 0 to validate it can be processes in the gallery. |
| 1073 | + * |
| 1074 | + * @param Collection $item |
| 1075 | + * @return bool |
| 1076 | + */ |
| 1077 | + private function isImageValid($item) |
| 1078 | + { |
| 1079 | + return $this->isImage($item->getBasename()) && $item->getSize() > 0; |
| 1080 | + } |
1067 | 1081 | }
|
0 commit comments