Skip to content

Commit d0924a4

Browse files
MAGETWO-51185: Product image cannot be loaded from product page if minification enabled
1 parent 072a1ae commit d0924a4

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct(ResolverInterface $fallback, AssetMinification $mini
3838
$this->fallback = $fallback;
3939
$this->minification = $minification;
4040
}
41+
4142
/**
4243
* Get path of file after using fallback rules
4344
*
@@ -52,9 +53,32 @@ public function __construct(ResolverInterface $fallback, AssetMinification $mini
5253
public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null)
5354
{
5455
$path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module);
55-
if (!$path && $file != ($newFile = $this->minification->removeMinifiedSign($file))) {
56-
$path = $this->fallback->resolve($type, $newFile, $area, $theme, $locale, $module);
56+
57+
/**
58+
* Minified version as priority one
59+
*/
60+
if ($path && $this->minification->isMinifiedFilename($path)) {
61+
return $path;
5762
}
58-
return $path;
63+
64+
/**
65+
* If minification is disabled - return already found path
66+
*/
67+
if (!$this->minification->isEnabled(pathinfo($file, PATHINFO_EXTENSION))) {
68+
return $path;
69+
}
70+
71+
/**
72+
* Try to find minified version of file,
73+
* or return already found path
74+
*/
75+
return $this->fallback->resolve(
76+
$type,
77+
$this->minification->addMinifiedSign($file),
78+
$area,
79+
$theme,
80+
$locale,
81+
$module
82+
) ?: $path;
5983
}
6084
}

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
@@ -72,7 +72,7 @@ public function testResolve(
7272
->willReturnMap([['css', $isEnabled]]);
7373
$this->assetMinificationMock
7474
->expects($this->any())
75-
->method('removeMinifiedSign')
75+
->method('addMinifiedSign')
7676
->with($requested)
7777
->willReturn($alternative);
7878

0 commit comments

Comments
 (0)