Skip to content

Commit c3f69fc

Browse files
authored
overloadable methods for resulting thumbnames
1 parent 6a9bd1d commit c3f69fc

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

core/src/HelperProcessor.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ public function __construct(Interfaces\CoreInterface $core)
1515
$this->core = $core;
1616
}
1717

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+
1828
public function phpThumb($input = '', $options = '', $webp = true)
1929
{
2030
if (!empty($input) && strtolower(substr($input, -4)) == '.svg') {
@@ -55,16 +65,17 @@ public function phpThumb($input = '', $options = '', $webp = true)
5565
}
5666

5767
$path_parts = pathinfo($input);
58-
$tmpImagesFolder = str_replace('assets/images', '', $path_parts['dirname']);
59-
$tmpImagesFolder = explode('/', $tmpImagesFolder);
6068
$ext = strtolower($path_parts['extension']);
6169
$options = 'f=' . (in_array($ext, array('png', 'gif', 'jpeg')) ? $ext : 'jpg&q=85') . '&' .
6270
strtr($options, array(',' => '&', '_' => '=', '{' => '[', '}' => ']'));
6371

72+
parse_str($options, $params);
6473

74+
$fName = $this->makeFilename($path_parts, $params);
6575

76+
$tmpImagesFolder = $this->makeFilePath($fName, $path_parts, $params);
77+
$tmpImagesFolder = explode('/', $tmpImagesFolder);
6678

67-
parse_str($options, $params);
6879
foreach ($tmpImagesFolder as $folder) {
6980
if (!empty($folder)) {
7081
$cacheFolder .= '/' . $folder;
@@ -81,7 +92,6 @@ public function phpThumb($input = '', $options = '', $webp = true)
8192
}
8293

8394
$fNamePref = rtrim($cacheFolder, '/') . '/';
84-
$fName = $path_parts['filename'];
8595
$fNameSuf = '-' .
8696
(isset($params['w']) ? $params['w'] : '') . 'x' . (isset($params['h']) ? $params['h'] : '') . '-' .
8797
substr(md5(serialize($params) . $fmtime), 0, 3) .
@@ -119,6 +129,4 @@ public function phpThumb($input = '', $options = '', $webp = true)
119129

120130
return $fNamePref . rawurlencode($fName) . $fNameSuf;
121131
}
122-
123-
124132
}

0 commit comments

Comments
 (0)