Skip to content

Commit c5b81bb

Browse files
committed
Merge branch 'release/1.0.10'
2 parents bca23d8 + 9d9d2b8 commit c5b81bb

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

CHANGELOG.md

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

3+
## 1.0.10 - 2018.01.29
4+
### Added
5+
* Added support for Yii2 aliases for `transcoderPath` & `transcoderUrl` settings in `config.php`
6+
7+
### Changed
8+
* Changed the default `config.php` to use `@webroot` and `@web` Yii2 aliases
9+
310
## 1.0.9 - 2018.01.25
411
### Changed
512
* Handle Asset Volumes that use aliases

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nystudio107/craft3-transcoder",
33
"description": "Transcode video & audio files to various formats, and provide video thumbnails",
44
"type": "craft-plugin",
5-
"version": "1.0.9",
5+
"version": "1.0.10",
66
"keywords": [
77
"craft",
88
"cms",

src/config.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
'ffprobeOptions' => '-v quiet -print_format json -show_format -show_streams',
3535

3636
// The path where the transcoded videos are stored; must have a trailing /
37-
'transcoderPath' => '{DOCUMENT_ROOT}/transcoder/',
37+
// Yii2 aliases are supported here
38+
'transcoderPath' => '@webroot/transcoder/',
3839

3940
// The URL where the transcoded videos are stored; must have a trailing /
40-
'transcoderUrl' => '/transcoder/',
41+
// Yii2 aliases are supported here
42+
'transcoderUrl' => '@web/transcoder/',
4143

4244
// Use a md5 hash for the filenames instead of parameterized naming
4345
'useHashedNames' => false,

src/models/Settings.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,19 @@ class Settings extends Model
4747

4848
/**
4949
* The path where the transcoded videos are stored; must have a trailing /
50+
* Yii2 aliases are supported here
5051
*
5152
* @var string
5253
*/
53-
public $transcoderPath = '{DOCUMENT_ROOT}/transcoder/';
54+
public $transcoderPath = '@webroot/transcoder/';
5455

5556
/**
5657
* The URL where the transcoded videos are stored; must have a trailing /
58+
* Yii2 aliases are supported here
5759
*
5860
* @var string
5961
*/
60-
public $transcoderUrl = '/transcoder/';
62+
public $transcoderUrl = '@web/transcoder/';
6163

6264
/**
6365
* Use a md5 hash for the filenames instead of parameterized naming

src/services/Transcode.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getVideoUrl($filePath, $videoOptions): string
9393
$filePath = $this->getAssetPath($filePath);
9494

9595
if (file_exists($filePath)) {
96-
$destVideoPath = $settings['transcoderPath'];
96+
$destVideoPath = Craft::getAlias($settings['transcoderPath']);
9797

9898
$videoOptions = $this->coalesceOptions("defaultVideoOptions", $videoOptions);
9999

@@ -181,7 +181,7 @@ public function getVideoUrl($filePath, $videoOptions): string
181181

182182
// If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding
183183
if (file_exists($destVideoPath) && (filemtime($destVideoPath) >= filemtime($filePath))) {
184-
$result = $settings['transcoderUrl'] . $destVideoFile;
184+
$result = Craft::getAlias($settings['transcoderUrl']) . $destVideoFile;
185185
} else {
186186
// Kick off the transcoding
187187
$pid = $this->executeShellCommand($ffmpegCmd);
@@ -212,7 +212,7 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions): string
212212
$filePath = $this->getAssetPath($filePath);
213213

214214
if (file_exists($filePath)) {
215-
$destThumbnailPath = $settings['transcoderPath'];
215+
$destThumbnailPath = Craft::getAlias($settings['transcoderPath']);
216216

217217
$thumbnailOptions = $this->coalesceOptions("defaultThumbnailOptions", $thumbnailOptions);
218218

@@ -250,7 +250,7 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions): string
250250
$shellOutput = $this->executeShellCommand($ffmpegCmd);
251251
Craft::info($ffmpegCmd, __METHOD__);
252252
}
253-
$result = $settings['transcoderUrl'] . $destThumbnailFile;
253+
$result = Craft::getAlias($settings['transcoderUrl']) . $destThumbnailFile;
254254
}
255255

256256
return $result;
@@ -274,7 +274,7 @@ public function getAudioUrl($filePath, $audioOptions): string
274274
$filePath = $this->getAssetPath($filePath);
275275

276276
if (file_exists($filePath)) {
277-
$destAudioPath = $settings['transcoderPath'];
277+
$destAudioPath = Craft::getAlias($settings['transcoderPath']);
278278

279279
$audioOptions = $this->coalesceOptions("defaultAudioOptions", $audioOptions);
280280

@@ -339,7 +339,7 @@ public function getAudioUrl($filePath, $audioOptions): string
339339

340340
// If the audio file already exists and hasn't been modified, return it. Otherwise, start it transcoding
341341
if (file_exists($destAudioPath) && (filemtime($destAudioPath) >= filemtime($filePath))) {
342-
$result = $settings['transcoderUrl'] . $destAudioFile;
342+
$result = Craft::getAlias($settings['transcoderUrl']) . $destAudioFile;
343343
} else {
344344
// Kick off the transcoding
345345
$pid = $this->executeShellCommand($ffmpegCmd);

0 commit comments

Comments
 (0)