Skip to content

Commit df3d1fb

Browse files
author
Natalia Momotenko
committed
Merge remote-tracking branch 'origin/develop' into PR-4
2 parents b1dc19c + 0834cd7 commit df3d1fb

File tree

21 files changed

+556
-486
lines changed

21 files changed

+556
-486
lines changed

app/code/Magento/Catalog/Model/Product/Image.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ public function setSize($size)
332332
list($width, $height) = explode('x', strtolower($size), 2);
333333
foreach (['width', 'height'] as $wh) {
334334
${$wh}
335-
= (int)${$wh};
335+
= (int)${$wh};
336336
if (empty(${$wh})) {
337337
${$wh}
338-
= null;
338+
= null;
339339
}
340340
}
341341

@@ -353,7 +353,8 @@ protected function _checkMemory($file = null)
353353
{
354354
return $this->_getMemoryLimit() > $this->_getMemoryUsage() + $this->_getNeedMemoryForFile(
355355
$file
356-
) || $this->_getMemoryLimit() == -1;
356+
)
357+
|| $this->_getMemoryLimit() == -1;
357358
}
358359

359360
/**
@@ -939,14 +940,17 @@ protected function _fileExists($filename)
939940
*/
940941
public function getResizedImageInfo()
941942
{
943+
$fileInfo = null;
942944
if ($this->_newFile === true) {
943-
$fileInfo = getimagesize(
944-
$this->_assetRepo->createAsset(
945-
"Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg"
946-
)->getSourceFile()
945+
$asset = $this->_assetRepo->createAsset(
946+
"Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg"
947947
);
948+
$img = $asset->getSourceFile();
949+
$fileInfo = getimagesize($img);
948950
} else {
949-
$fileInfo = getimagesize($this->_mediaDirectory->getAbsolutePath($this->_newFile));
951+
if ($this->_mediaDirectory->isFile($this->_mediaDirectory->getAbsolutePath($this->_newFile))) {
952+
$fileInfo = getimagesize($this->_mediaDirectory->getAbsolutePath($this->_newFile));
953+
}
950954
}
951955
return $fileInfo;
952956
}

app/code/Magento/ProductVideo/Helper/Media.php

Lines changed: 13 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
use Magento\Framework\App\Area;
1010
use Magento\Framework\App\Helper\Context;
11-
use Magento\Framework\View\ConfigInterface;
12-
use Magento\Framework\View\DesignInterface;
1311

1412
/**
1513
* Helper to get attributes for video
@@ -21,81 +19,37 @@ class Media extends \Magento\Framework\App\Helper\AbstractHelper
2119
*/
2220
const MODULE_NAME = 'Magento_ProductVideo';
2321

24-
/**
25-
* Video play attribute
26-
*/
27-
const NODE_CONFIG_PLAY_IF_BASE = 'play_if_base';
28-
29-
/**
30-
* Video stop attribute
31-
*/
32-
const NODE_CONFIG_SHOW_RELATED = 'show_related';
33-
34-
/**
35-
* Video color attribute
36-
*/
37-
const NODE_CONFIG_VIDEO_AUTO_RESTART = 'video_auto_restart';
38-
39-
/**
40-
* Media config node
41-
*/
42-
const MEDIA_TYPE_CONFIG_NODE = 'videos';
43-
4422
/**
4523
* Configuration path
4624
*/
4725
const XML_PATH_YOUTUBE_API_KEY = 'catalog/product_video/youtube_api_key';
4826

4927
/**
50-
* @var ConfigInterface
28+
* Configuration path for video play
5129
*/
52-
protected $viewConfig;
30+
const XML_PATH_PLAY_IF_BASE = 'catalog/product_video/play_if_base';
5331

5432
/**
55-
* Theme
56-
*
57-
* @var DesignInterface
33+
* Configuration path for show related
34+
*/
35+
const XML_PATH_SHOW_RELATED = 'catalog/product_video/show_related';
36+
/**
37+
* Configuration path for video auto restart
5838
*/
59-
protected $currentTheme;
39+
const XML_PATH_VIDEO_AUTO_RESTART = 'catalog/product_video/video_auto_restart';
6040

6141
/**
62-
* Cached video config
42+
* Media config node
6343
*/
64-
protected $cachedVideoConfig;
44+
const MEDIA_TYPE_CONFIG_NODE = 'videos';
6545

6646
/**
67-
* @param ConfigInterface $configInterface
68-
* @param DesignInterface $designInterface
6947
* @param Context $context
7048
*/
7149
public function __construct(
72-
ConfigInterface $configInterface,
73-
DesignInterface $designInterface,
7450
Context $context
7551
) {
7652
parent::__construct($context);
77-
$this->viewConfig = $configInterface;
78-
$this->currentTheme = $designInterface->getDesignTheme();
79-
$this->initConfig();
80-
}
81-
82-
/**
83-
* Cached video config
84-
*
85-
* @return $this
86-
*/
87-
protected function initConfig()
88-
{
89-
if ($this->cachedVideoConfig === null) {
90-
$this->cachedVideoConfig = $this->viewConfig->getViewConfig(
91-
[
92-
'area' => Area::AREA_FRONTEND,
93-
'themeModel' => $this->currentTheme
94-
]
95-
);
96-
}
97-
98-
return $this;
9953
}
10054

10155
/**
@@ -105,14 +59,7 @@ protected function initConfig()
10559
*/
10660
public function getPlayIfBaseAttribute()
10761
{
108-
$videoAttributes = $this->cachedVideoConfig->getMediaAttributes(
109-
self::MODULE_NAME,
110-
self::MEDIA_TYPE_CONFIG_NODE,
111-
self::NODE_CONFIG_PLAY_IF_BASE
112-
);
113-
if (isset($videoAttributes[self::NODE_CONFIG_PLAY_IF_BASE])) {
114-
return $videoAttributes[self::NODE_CONFIG_PLAY_IF_BASE];
115-
}
62+
return $this->scopeConfig->getValue(self::XML_PATH_PLAY_IF_BASE);
11663
}
11764

11865
/**
@@ -122,14 +69,7 @@ public function getPlayIfBaseAttribute()
12269
*/
12370
public function getShowRelatedAttribute()
12471
{
125-
$videoAttributes = $this->cachedVideoConfig->getMediaAttributes(
126-
self::MODULE_NAME,
127-
self::MEDIA_TYPE_CONFIG_NODE,
128-
self::NODE_CONFIG_SHOW_RELATED
129-
);
130-
if (isset($videoAttributes[self::NODE_CONFIG_SHOW_RELATED])) {
131-
return $videoAttributes[self::NODE_CONFIG_SHOW_RELATED];
132-
}
72+
return $this->scopeConfig->getValue(self::XML_PATH_SHOW_RELATED);
13373
}
13474

13575
/**
@@ -139,14 +79,7 @@ public function getShowRelatedAttribute()
13979
*/
14080
public function getVideoAutoRestartAttribute()
14181
{
142-
$videoAttributes = $this->cachedVideoConfig->getMediaAttributes(
143-
self::MODULE_NAME,
144-
self::MEDIA_TYPE_CONFIG_NODE,
145-
self::NODE_CONFIG_VIDEO_AUTO_RESTART
146-
);
147-
if (isset($videoAttributes[self::NODE_CONFIG_VIDEO_AUTO_RESTART])) {
148-
return $videoAttributes[self::NODE_CONFIG_VIDEO_AUTO_RESTART];
149-
}
82+
return $this->scopeConfig->getValue(self::XML_PATH_VIDEO_AUTO_RESTART);
15083
}
15184

15285
/**

0 commit comments

Comments
 (0)