Skip to content

Commit 50e969c

Browse files
committed
Both aliases and environment variables are now supported where previously only aliases were
Signed-off-by: Andrew Welch <andrew@nystudio107.com>
1 parent 484ce9d commit 50e969c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Transcoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function clearAllCaches()
9292
$transcoderPaths = self::$plugin->getSettings()->transcoderPaths;
9393

9494
foreach ($transcoderPaths as $key => $value) {
95-
$dir = Craft::getAlias($value);
95+
$dir = Craft::parseEnv($value);
9696
try {
9797
FileHelper::clearDirectory($dir);
9898
Craft::info(

src/services/Transcode.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getVideoUrl($filePath, $videoOptions, $generate = true): string
108108

109109
if (!empty($filePath)) {
110110
$destVideoPath = $settings['transcoderPaths']['video'].$subfolder ?? $settings['transcoderPaths']['default'];
111-
$destVideoPath = Craft::getAlias($destVideoPath);
111+
$destVideoPath = Craft::parseEnv($destVideoPath);
112112
$videoOptions = $this->coalesceOptions('defaultVideoOptions', $videoOptions);
113113

114114
// Get the video encoder presets to use
@@ -200,7 +200,7 @@ public function getVideoUrl($filePath, $videoOptions, $generate = true): string
200200
// If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding
201201
if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
202202
$url = $settings['transcoderUrls']['video'].$subfolder ?? $settings['transcoderUrls']['default'];
203-
$result = Craft::getAlias($url).$destVideoFile;
203+
$result = Craft::parseEnv($url).$destVideoFile;
204204
// skip encoding
205205
} elseif (!$generate) {
206206
$result = "";
@@ -243,7 +243,7 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions, $generate = t
243243

244244
if (!empty($filePath)) {
245245
$destThumbnailPath = $settings['transcoderPaths']['thumbnail'].$subfolder ?? $settings['transcoderPaths']['default'];
246-
$destThumbnailPath = Craft::getAlias($destThumbnailPath);
246+
$destThumbnailPath = Craft::parseEnv($destThumbnailPath);
247247

248248
$thumbnailOptions = $this->coalesceOptions('defaultThumbnailOptions', $thumbnailOptions);
249249

@@ -303,7 +303,7 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions, $generate = t
303303
$result = $destThumbnailPath;
304304
} else {
305305
$url = $settings['transcoderUrls']['thumbnail'].$subfolder ?? $settings['transcoderUrls']['default'];
306-
$result = Craft::getAlias($url).$destThumbnailFile;
306+
$result = Craft::parseEnv($url).$destThumbnailFile;
307307
}
308308
}
309309

@@ -334,7 +334,7 @@ public function getAudioUrl($filePath, $audioOptions): string
334334

335335
if (!empty($filePath)) {
336336
$destAudioPath = $settings['transcoderPaths']['audio'].$subfolder ?? $settings['transcoderPaths']['default'];
337-
$destAudioPath = Craft::getAlias($destAudioPath);
337+
$destAudioPath = Craft::parseEnv($destAudioPath);
338338

339339
$audioOptions = $this->coalesceOptions('defaultAudioOptions', $audioOptions);
340340

@@ -423,15 +423,15 @@ public function getAudioUrl($filePath, $audioOptions): string
423423
// If the audio file already exists and hasn't been modified, return it. Otherwise, start it transcoding
424424
if (file_exists($destAudioPath) && (@filemtime($destAudioPath) >= @filemtime($filePath))) {
425425
$url = $settings['transcoderUrls']['audio'].$subfolder ?? $settings['transcoderUrls']['default'];
426-
$result = Craft::getAlias($url).$destAudioFile;
426+
$result = Craft::parseEnv($url).$destAudioFile;
427427
} else {
428428
// Kick off the transcoding
429429
$pid = $this->executeShellCommand($ffmpegCmd);
430430

431431
if ($synchronous) {
432432
Craft::info($ffmpegCmd, __METHOD__);
433433
$url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default'];
434-
$result = Craft::getAlias($url).$destAudioFile;
434+
$result = Craft::parseEnv($url).$destAudioFile;
435435
} else {
436436
Craft::info($ffmpegCmd."\nffmpeg PID: ".$pid, __METHOD__);
437437
// Create a lockfile in tmp
@@ -629,7 +629,7 @@ public function getGifUrl($filePath, $gifOptions): string
629629
if (!empty($filePath)) {
630630
// Dest path
631631
$destVideoPath = $settings['transcoderPaths']['gif'].$subfolder ?? $settings['transcoderPaths']['default'];
632-
$destVideoPath = Craft::getAlias($destVideoPath);
632+
$destVideoPath = Craft::parseEnv($destVideoPath);
633633

634634
// Options
635635
$gifOptions = $this->coalesceOptions('defaultGifOptions', $gifOptions);
@@ -683,7 +683,7 @@ public function getGifUrl($filePath, $gifOptions): string
683683
// If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding
684684
if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
685685
$url = $settings['transcoderUrls']['gif'].$subfolder ?? $settings['transcoderUrls']['default'];
686-
$result = Craft::getAlias($url).$destVideoFile;
686+
$result = Craft::parseEnv($url).$destVideoFile;
687687
} else {
688688
// Kick off the transcoding
689689
$pid = $this->executeShellCommand($ffmpegCmd);
@@ -785,7 +785,7 @@ protected function getAssetPath($filePath): string
785785
}
786786
}
787787

788-
$filePath = Craft::getAlias($filePath);
788+
$filePath = Craft::parseEnv($filePath);
789789

790790
// Make sure that $filePath is either an existing file, or a valid URL
791791
if (!file_exists($filePath)) {

0 commit comments

Comments
 (0)