@@ -15,6 +15,16 @@ public function __construct(Interfaces\CoreInterface $core)
15
15
$ this ->core = $ core ;
16
16
}
17
17
18
+ protected function makeFilename ($ pathinfo , $ params )
19
+ {
20
+ return $ pathinfo ['filename ' ];
21
+ }
22
+
23
+ protected function makeFilePath ($ newFilename , $ pathinfo , $ params )
24
+ {
25
+ return str_replace ('assets/images ' , '' , $ path_parts ['dirname ' ]);
26
+ }
27
+
18
28
public function phpThumb ($ input = '' , $ options = '' , $ webp = true )
19
29
{
20
30
if (!empty ($ input ) && strtolower (substr ($ input , -4 )) == '.svg ' ) {
@@ -55,16 +65,17 @@ public function phpThumb($input = '', $options = '', $webp = true)
55
65
}
56
66
57
67
$ path_parts = pathinfo ($ input );
58
- $ tmpImagesFolder = str_replace ('assets/images ' , '' , $ path_parts ['dirname ' ]);
59
- $ tmpImagesFolder = explode ('/ ' , $ tmpImagesFolder );
60
68
$ ext = strtolower ($ path_parts ['extension ' ]);
61
69
$ options = 'f= ' . (in_array ($ ext , array ('png ' , 'gif ' , 'jpeg ' )) ? $ ext : 'jpg&q=85 ' ) . '& ' .
62
70
strtr ($ options , array (', ' => '& ' , '_ ' => '= ' , '{ ' => '[ ' , '} ' => '] ' ));
63
71
72
+ parse_str ($ options , $ params );
64
73
74
+ $ fName = $ this ->makeFilename ($ path_parts , $ params );
65
75
76
+ $ tmpImagesFolder = $ this ->makeFilePath ($ fName , $ path_parts , $ params );
77
+ $ tmpImagesFolder = explode ('/ ' , $ tmpImagesFolder );
66
78
67
- parse_str ($ options , $ params );
68
79
foreach ($ tmpImagesFolder as $ folder ) {
69
80
if (!empty ($ folder )) {
70
81
$ cacheFolder .= '/ ' . $ folder ;
@@ -81,7 +92,6 @@ public function phpThumb($input = '', $options = '', $webp = true)
81
92
}
82
93
83
94
$ fNamePref = rtrim ($ cacheFolder , '/ ' ) . '/ ' ;
84
- $ fName = $ path_parts ['filename ' ];
85
95
$ fNameSuf = '- ' .
86
96
(isset ($ params ['w ' ]) ? $ params ['w ' ] : '' ) . 'x ' . (isset ($ params ['h ' ]) ? $ params ['h ' ] : '' ) . '- ' .
87
97
substr (md5 (serialize ($ params ) . $ fmtime ), 0 , 3 ) .
@@ -119,6 +129,4 @@ public function phpThumb($input = '', $options = '', $webp = true)
119
129
120
130
return $ fNamePref . rawurlencode ($ fName ) . $ fNameSuf ;
121
131
}
122
-
123
-
124
132
}
0 commit comments