@@ -631,17 +631,7 @@ public function resizeFile($source, $keepRatio = true)
631
631
632
632
$ image ->keepAspectRatio ($ keepRatio );
633
633
634
- list ($ imageWidth , $ imageHeight ) = @getimagesize ($ source );
635
-
636
- if ($ imageWidth && $ imageHeight ) {
637
- $ configWidth = $ this ->_resizeParameters ['width ' ];
638
- $ configHeight = $ this ->_resizeParameters ['height ' ];
639
- $ imageWidth = $ configWidth > $ imageWidth ? $ imageWidth : $ configWidth ;
640
- $ imageHeight = $ configHeight > $ imageHeight ? $ imageHeight : $ configHeight ;
641
- } else {
642
- $ imageWidth = $ this ->_resizeParameters ['width ' ];
643
- $ imageHeight = $ this ->_resizeParameters ['height ' ];
644
- }
634
+ list ($ imageWidth , $ imageHeight ) = $ this ->getResizedParams ($ source );
645
635
646
636
$ image ->resize ($ imageWidth , $ imageHeight );
647
637
$ dest = $ targetDir . '/ ' . $ this ->ioFile ->getPathInfo ($ source )['basename ' ];
@@ -652,6 +642,29 @@ public function resizeFile($source, $keepRatio = true)
652
642
return false ;
653
643
}
654
644
645
+ /**
646
+ * Return width height for the image resizing.
647
+ *
648
+ * @param string $source
649
+ */
650
+ private function getResizedParams (string $ source ): array
651
+ {
652
+ $ configWidth = $ this ->_resizeParameters ['width ' ];
653
+ $ configHeight = $ this ->_resizeParameters ['height ' ];
654
+
655
+ //phpcs:ignore Generic.PHP.NoSilencedErrors
656
+ list ($ imageWidth , $ imageHeight ) = @getimagesize ($ source );
657
+
658
+ if ($ imageWidth && $ imageHeight ) {
659
+ $ imageWidth = $ configWidth > $ imageWidth ? $ imageWidth : $ configWidth ;
660
+ $ imageHeight = $ configHeight > $ imageHeight ? $ imageHeight : $ configHeight ;
661
+ } else {
662
+ return [$ configWidth , $ configHeight ];
663
+ }
664
+
665
+ return [$ imageWidth , $ imageHeight ];
666
+ }
667
+
655
668
/**
656
669
* Resize images on the fly in controller action
657
670
*
0 commit comments