Skip to content

Commit 4ff4851

Browse files
committed
Merge branch 'release/1.2.11' into v1
2 parents 0c966e3 + 349d044 commit 4ff4851

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Transcoder Changelog
22

3+
## 1.2.11 - 2020.03.11
4+
### Added
5+
* Transcoder now requires Craft CMS 3.1.0 or later
6+
* Both aliases and environment variables are now supported where previously only aliases were
7+
8+
### Fixed
9+
* Only swap in a thumbnail for videos if a thumbnail is successfully returned
10+
311
## 1.2.10 - 2020.02.25
412
### Added
513
* Added `-vn` flag for audio transcoding to remove video tracks on transcoded audio

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nystudio107/craft-transcoder",
33
"description": "Transcode video & audio files to various formats, and provide video thumbnails",
44
"type": "craft-plugin",
5-
"version": "1.2.10",
5+
"version": "1.2.11",
66
"keywords": [
77
"craft",
88
"cms",
@@ -28,7 +28,7 @@
2828
}
2929
],
3030
"require": {
31-
"craftcms/cms": "^3.0.0",
31+
"craftcms/cms": "^3.1.0",
3232
"mikehaertl/php-shellcommand": "~1.2"
3333
},
3434
"autoload": {

src/Transcoder.php

Lines changed: 5 additions & 2 deletions
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(
@@ -156,7 +156,10 @@ function (AssetThumbEvent $event) {
156156
/** @var Asset $asset */
157157
$asset = $event->asset;
158158
if (AssetsHelper::getFileKindByExtension($asset->filename) === Asset::KIND_VIDEO) {
159-
$event->path = Transcoder::$plugin->transcode->handleGetAssetThumbPath($event);
159+
$path = Transcoder::$plugin->transcode->handleGetAssetThumbPath($event);
160+
if (!empty($path)) {
161+
$event->path = $path;
162+
}
160163
}
161164
}
162165
);

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)