Skip to content

Commit 209fec5

Browse files
committed
#86 - Allow wildcards in conversion chain
1 parent baaa335 commit 209fec5

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/Configuration/ConfigurationDefaults.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,21 @@ public function __construct(&$settings) {
150150
'chain' => 'rtf->ps->pdf',
151151
),
152152
),
153-
'webp->jpg' => array(
154-
'webp->png->jpg' => array(
153+
'webp->(jpg|gif|svg|tiff|wmf)' => array(
154+
'webp->png->img' => array(
155155
'#engine' => 'Chain',
156-
'chain' => 'webp->png->jpg',
156+
'chain' => 'webp->png->*',
157157
),
158158
),
159159
'webp->png' => array(
160160
'webp:default' => array(
161161
'#engine' => 'Convert\\WebP',
162162
),
163163
),
164-
'jpg->webp' => array(
164+
'(jpg|gif|svg|tiff|wmf)->webp' => array(
165165
'jpg->png->webp' => array(
166166
'#engine' => 'Chain',
167-
'chain' => 'jpg->png->webp',
167+
'chain' => '*->png->webp',
168168
),
169169
),
170170
'png->webp' => array(

src/Engine/Chain.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ class Chain extends EngineBase {
1414
public function convertFile($source, $destination) {
1515
$links = explode('->', $this->configuration['chain']);
1616

17+
// Allow wildcards for the start/end
18+
if ($links[0] === '*') {
19+
$links[0] = $this->conversion[0];
20+
}
21+
if ($links[sizeof($links) - 1] === '*') {
22+
$links[sizeof($links) - 1] = $this->conversion[1];
23+
}
24+
25+
// Iterate through the chain.
1726
$s_path = $this->getTempFile(array_shift($links));
1827
copy($source, $s_path);
1928
while (!empty($links)) {

0 commit comments

Comments
 (0)