Square only third-level category uploads
This commit is contained in:
@@ -427,7 +427,13 @@ class AdvancedMegaMenu extends Module implements WidgetInterface
|
||||
}
|
||||
|
||||
$preset = (string) Tools::getValue('preset', 'default');
|
||||
$storedPath = $this->storeUploadedImage($_FILES['image'], $preset);
|
||||
$menuDepth = (int) Tools::getValue('menu_depth', -1);
|
||||
$menuType = (string) Tools::getValue('menu_type', '');
|
||||
$storedPath = $this->storeUploadedImage(
|
||||
$_FILES['image'],
|
||||
$preset,
|
||||
$preset === 'menu_icon' && $menuDepth >= 2 && $menuType === 'category'
|
||||
);
|
||||
header('Content-Type: application/json');
|
||||
exit(json_encode([
|
||||
'error' => false,
|
||||
@@ -439,7 +445,7 @@ class AdvancedMegaMenu extends Module implements WidgetInterface
|
||||
/**
|
||||
* @param array<string, mixed> $file
|
||||
*/
|
||||
private function storeUploadedImage(array $file, string $preset = 'default'): string
|
||||
private function storeUploadedImage(array $file, string $preset = 'default', bool $forceSquare = false): string
|
||||
{
|
||||
$uploadDir = $this->getLocalPath() . 'views/img/uploads/';
|
||||
if (!is_dir($uploadDir)) {
|
||||
@@ -456,7 +462,7 @@ class AdvancedMegaMenu extends Module implements WidgetInterface
|
||||
}
|
||||
|
||||
$converted = false;
|
||||
if ($preset === 'menu_icon') {
|
||||
if ($preset === 'menu_icon' && $forceSquare) {
|
||||
$converted = $this->convertImageToSquareWebp($originalPath, $targetPath, 250);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user