@@ -152,6 +152,11 @@ class Storage extends \Magento\Framework\DataObject
152
152
*/
153
153
private $ ioFile ;
154
154
155
+ /**
156
+ * @var \Magento\Framework\File\Mime|null
157
+ */
158
+ private $ mime ;
159
+
155
160
/**
156
161
* Construct
157
162
*
@@ -197,6 +202,7 @@ public function __construct(
197
202
array $ data = [],
198
203
\Magento \Framework \Filesystem \DriverInterface $ file = null ,
199
204
\Magento \Framework \Filesystem \Io \File $ ioFile = null ,
205
+ \Magento \Framework \File \Mime $ mime = null ,
200
206
\Psr \Log \LoggerInterface $ logger = null
201
207
) {
202
208
$ this ->_session = $ session ;
@@ -217,6 +223,7 @@ public function __construct(
217
223
$ this ->_dirs = $ dirs ;
218
224
$ this ->file = $ file ?: ObjectManager::getInstance ()->get (\Magento \Framework \Filesystem \Driver \File::class);
219
225
$ this ->ioFile = $ ioFile ?: ObjectManager::getInstance ()->get (\Magento \Framework \Filesystem \Io \File::class);
226
+ $ this ->mime = $ mime ?: ObjectManager::getInstance ()->get (\Magento \Framework \File \Mime::class);
220
227
parent ::__construct ($ data );
221
228
}
222
229
@@ -362,7 +369,7 @@ public function getFilesCollection($path, $type = null)
362
369
$ item ->setUrl ($ this ->_cmsWysiwygImages ->getCurrentUrl () . $ item ->getBasename ());
363
370
$ itemStats = $ this ->file ->stat ($ item ->getFilename ());
364
371
$ item ->setSize ($ itemStats ['size ' ]);
365
- $ item ->setMimeType (\mime_content_type ($ item ->getFilename ()));
372
+ $ item ->setMimeType ($ this -> mime -> getMimeType ($ item ->getFilename ()));
366
373
367
374
if ($ this ->isImage ($ item ->getBasename ())) {
368
375
$ thumbUrl = $ this ->getThumbnailUrl ($ item ->getFilename (), true );
@@ -647,7 +654,7 @@ public function resizeFile($source, $keepRatio = true)
647
654
$ image ->keepAspectRatio ($ keepRatio );
648
655
649
656
list ($ imageWidth , $ imageHeight ) = $ this ->getResizedParams ($ source );
650
-
657
+
651
658
$ image ->resize ($ imageWidth , $ imageHeight );
652
659
$ dest = $ targetDir . '/ ' . $ this ->ioFile ->getPathInfo ($ source )['basename ' ];
653
660
$ image ->save ($ dest );
@@ -670,7 +677,7 @@ private function getResizedParams(string $source): array
670
677
671
678
//phpcs:ignore Generic.PHP.NoSilencedErrors
672
679
list ($ imageWidth , $ imageHeight ) = @getimagesize ($ source );
673
-
680
+
674
681
if ($ imageWidth && $ imageHeight ) {
675
682
$ imageWidth = $ configWidth > $ imageWidth ? $ imageWidth : $ configWidth ;
676
683
$ imageHeight = $ configHeight > $ imageHeight ? $ imageHeight : $ configHeight ;
@@ -679,7 +686,7 @@ private function getResizedParams(string $source): array
679
686
}
680
687
return [$ configWidth , $ configHeight ];
681
688
}
682
-
689
+
683
690
/**
684
691
* Resize images on the fly in controller action
685
692
*
0 commit comments