Skip to content

Commit 513a671

Browse files
MAGETWO-51185: Product image cannot be loaded from product page if minification enabled
1 parent 84971cd commit 513a671

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Minification.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,41 @@ public function __construct(ResolverInterface $fallback, AssetMinification $mini
5252
*/
5353
public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null)
5454
{
55+
$fileExtension = pathinfo($file, PATHINFO_EXTENSION);
56+
57+
if ($fileExtension === 'js') {
58+
return $this->resolveJsMinification($type, $file, $area, $theme, $locale, $module);
59+
}
60+
61+
// Leave BC way of resolving
62+
$path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module);
63+
64+
if (!$path && $file != ($newFile = $this->minification->removeMinifiedSign($file))) {
65+
$path = $this->fallback->resolve($type, $newFile, $area, $theme, $locale, $module);
66+
}
67+
68+
return $path;
69+
}
70+
71+
/**
72+
* Get path of file after using fallback rules
73+
*
74+
* @param string $type
75+
* @param string $file
76+
* @param string|null $area
77+
* @param ThemeInterface|null $theme
78+
* @param string|null $locale
79+
* @param string|null $module
80+
* @return string|false
81+
*/
82+
private function resolveJsMinification(
83+
$type,
84+
$file,
85+
$area = null,
86+
ThemeInterface $theme = null,
87+
$locale = null,
88+
$module = null
89+
) {
5590
$path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module);
5691

5792
/**
@@ -64,7 +99,7 @@ public function resolve($type, $file, $area = null, ThemeInterface $theme = null
6499
/**
65100
* If minification is disabled - return already found path
66101
*/
67-
if (!$this->minification->isEnabled(pathinfo($file, PATHINFO_EXTENSION))) {
102+
if (!$this->minification->isEnabled('js')) {
68103
return $path;
69104
}
70105

lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/MinificationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testResolve(
7373
->willReturnMap([['css', $isEnabled]]);
7474
$this->assetMinificationMock
7575
->expects($this->any())
76-
->method('addMinifiedSign')
76+
->method('removeMinifiedSign')
7777
->with($requested)
7878
->willReturn($alternative);
7979

0 commit comments

Comments
 (0)