Skip to content

Commit 402f9cf

Browse files
committed
ACP2E-1353: allow image/x-icon favicon; cr comments
1 parent 5a4c68b commit 402f9cf

File tree

3 files changed

+3
-28
lines changed

3 files changed

+3
-28
lines changed

app/code/Magento/MediaStorage/Model/File/Validator/Image.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Image extends AbstractValidator
3030
'jpg' => 'image/jpeg',
3131
'gif' => 'image/gif',
3232
'bmp' => 'image/bmp',
33-
'ico' => [ 'image/vnd.microsoft.icon', 'image/x-icon']
33+
'ico' => ['image/vnd.microsoft.icon', 'image/x-icon']
3434
];
3535

3636
/**
@@ -48,11 +48,6 @@ class Image extends AbstractValidator
4848
*/
4949
private $file;
5050

51-
/**
52-
* @var ConfigInterface
53-
*/
54-
private $config;
55-
5651
/**
5752
* @var LoggerInterface
5853
*/
@@ -62,20 +57,17 @@ class Image extends AbstractValidator
6257
* @param Mime $fileMime
6358
* @param Factory $imageFactory
6459
* @param File $file
65-
* @param ConfigInterface|null $config
6660
* @param LoggerInterface|null $logger
6761
*/
6862
public function __construct(
6963
Mime $fileMime,
7064
Factory $imageFactory,
7165
File $file,
72-
ConfigInterface $config = null,
7366
LoggerInterface $logger = null
7467
) {
7568
$this->fileMime = $fileMime;
7669
$this->imageFactory = $imageFactory;
7770
$this->file = $file;
78-
$this->config = $config ?? ObjectManager::getInstance()->get(ConfigInterface::class);
7971
$this->logger = $logger ?? ObjectManager::getInstance()->get(LoggerInterface::class);
8072

8173
parent::__construct();
@@ -93,11 +85,6 @@ public function isValid($filePath): bool
9385
try {
9486
$image = $this->imageFactory->create($filePath);
9587
$image->open();
96-
} catch (\InvalidArgumentException $e) {
97-
if (stripos($fileMimeType, 'icon') !== false) {
98-
$image = $this->imageFactory->create($filePath, $this->getNonDefaultAdapter());
99-
$image->open();
100-
}
10188
} catch (\Exception $e) {
10289
$isValid = false;
10390
$this->logger->critical($e, ['exception' => $e]);
@@ -106,17 +93,4 @@ public function isValid($filePath): bool
10693

10794
return $isValid;
10895
}
109-
110-
/**
111-
* Get non default image adapter
112-
*
113-
* @return string|null
114-
*/
115-
private function getNonDefaultAdapter(): ?string
116-
{
117-
$defaultAdapter = $this->config->getAdapterAlias();
118-
$adapters = $this->config->getAdapters();
119-
unset($adapters[$defaultAdapter]);
120-
return array_key_first($adapters) ?? null;
121-
}
12296
}

app/code/Magento/Theme/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Configuration,Configuration
153153
"Other Settings","Other Settings"
154154
"HTML Head","HTML Head"
155155
"Allowed file types: ico, png, gif, jpg, jpeg, apng. Not all browsers support all these formats!","Allowed file types: ico, png, gif, jpg, jpeg, apng. Not all browsers support all these formats!"
156+
"Not all browsers support all these formats! Note: ICO file type is supported by ImageMagik adapter that can be set from Store / Configuration / Developer / Image Processing Settings.","Not all browsers support all these formats! Note: ICO file type is supported by ImageMagik adapter that can be set from Store / Configuration / Developer / Image Processing Settings."
156157
"Favicon Icon","Favicon Icon"
157158
"Default Page Title","Default Page Title"
158159
"Page Title Prefix","Page Title Prefix"

app/code/Magento/Theme/view/adminhtml/ui_component/design_config_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</settings>
5757
<field name="head_shortcut_icon" formElement="imageUploader">
5858
<settings>
59-
<notice translate="true">Not all browsers support all these formats!</notice>
59+
<notice translate="true">Not all browsers support all these formats! Note: ICO file type is supported by ImageMagik adapter that can be set from Store / Configuration / Developer / Image Processing Settings.</notice>
6060
<label translate="true">Favicon Icon</label>
6161
<componentType>imageUploader</componentType>
6262
</settings>

0 commit comments

Comments
 (0)