91 \
Magento\Framework\View\ConfigInterface $configInterface
99 $this->viewConfig = $configInterface;
109 $generationPath = $swatchType .
'/' . $this->
getFolderNameSize($swatchType) . $file;
110 $absoluteImagePath = $this->mediaDirectory
112 if (!file_exists($absoluteImagePath)) {
115 }
catch (\Exception $e) {
128 public function moveImageFromTmp($file)
130 if (strrpos($file,
'.tmp') == strlen($file) - 4) {
131 $file = substr($file, 0, strlen($file) - 4);
138 if ($storageHelper->checkDbUsage()) {
139 $storageHelper->renameFile(
140 $this->mediaConfig->getTmpMediaShortUrl($file),
141 $this->mediaConfig->getMediaShortUrl($destinationFile)
144 $this->mediaDirectory->delete($this->mediaConfig->getTmpMediaPath($file));
147 $this->mediaDirectory->renameFile(
148 $this->mediaConfig->getTmpMediaPath($file),
153 return str_replace(
'\\',
'/', $destinationFile);
164 if ($this->fileStorageDb->checkDbUsage()) {
165 $destFile = $this->fileStorageDb->getUniqueFilename(
166 $this->mediaConfig->getBaseMediaUrlAddition(),
171 $this->mediaDirectory->getAbsolutePath($this->getAttributeSwatchPath($file))
187 foreach ($this->swatchImageTypes as $swatchType) {
190 $image = $this->imageFactory->create($absoluteImagePath);
192 $image->resize($imageConfig[$swatchType][
'width'], $imageConfig[$swatchType][
'height']);
194 $image->save($swatchNamePath[
'path_for_save'], $swatchNamePath[
'name']);
209 $image->constrainOnly(
true);
210 $image->keepAspectRatio(
true);
213 $image->keepTransparency(
true);
214 $image->backgroundColor([255, 255, 255]);
230 $absolutePath = $this->mediaDirectory->getAbsolutePath($this->
getSwatchCachePath($swatchType));
246 if ($imageConfig ===
null) {
249 return $imageConfig[$swatchType][
'width'] .
'x' . $imageConfig[$swatchType][
'height'];
259 if (!$this->imageConfig) {
260 $this->imageConfig = $this->viewConfig->getViewConfig()->getMediaEntities(
266 return $this->imageConfig;
279 $filePath = implode(
'/', $fileArray);
280 return [
'name' =>
$fileName,
'path' => $filePath];
290 return $this->storeManager
324 return self::SWATCH_MEDIA_PATH .
'/' . $swatchType .
'/';
335 return ltrim(str_replace(
'\\',
'/', $file),
'/');
if($_imageTitle=$block->escapeHtml($block->getCurrentImage() ->getLabel())) $imageUrl
const MEDIA_TYPE_CONFIG_NODE
static getNewFileName($destinationFile)