Skip to content

Commit

Permalink
Merge branch 'release/1.0.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 29, 2018
2 parents bca23d8 + 9d9d2b8 commit c5b81bb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Transcoder Changelog

## 1.0.10 - 2018.01.29
### Added
* Added support for Yii2 aliases for `transcoderPath` & `transcoderUrl` settings in `config.php`

### Changed
* Changed the default `config.php` to use `@webroot` and `@web` Yii2 aliases

## 1.0.9 - 2018.01.25
### Changed
* Handle Asset Volumes that use aliases
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft3-transcoder",
"description": "Transcode video & audio files to various formats, and provide video thumbnails",
"type": "craft-plugin",
"version": "1.0.9",
"version": "1.0.10",
"keywords": [
"craft",
"cms",
Expand Down
6 changes: 4 additions & 2 deletions src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
'ffprobeOptions' => '-v quiet -print_format json -show_format -show_streams',

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

// The URL where the transcoded videos are stored; must have a trailing /
'transcoderUrl' => '/transcoder/',
// Yii2 aliases are supported here
'transcoderUrl' => '@web/transcoder/',

// Use a md5 hash for the filenames instead of parameterized naming
'useHashedNames' => false,
Expand Down
6 changes: 4 additions & 2 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ class Settings extends Model

/**
* The path where the transcoded videos are stored; must have a trailing /
* Yii2 aliases are supported here
*
* @var string
*/
public $transcoderPath = '{DOCUMENT_ROOT}/transcoder/';
public $transcoderPath = '@webroot/transcoder/';

/**
* The URL where the transcoded videos are stored; must have a trailing /
* Yii2 aliases are supported here
*
* @var string
*/
public $transcoderUrl = '/transcoder/';
public $transcoderUrl = '@web/transcoder/';

/**
* Use a md5 hash for the filenames instead of parameterized naming
Expand Down
12 changes: 6 additions & 6 deletions src/services/Transcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getVideoUrl($filePath, $videoOptions): string
$filePath = $this->getAssetPath($filePath);

if (file_exists($filePath)) {
$destVideoPath = $settings['transcoderPath'];
$destVideoPath = Craft::getAlias($settings['transcoderPath']);

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

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

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

if (file_exists($filePath)) {
$destThumbnailPath = $settings['transcoderPath'];
$destThumbnailPath = Craft::getAlias($settings['transcoderPath']);

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

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

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

if (file_exists($filePath)) {
$destAudioPath = $settings['transcoderPath'];
$destAudioPath = Craft::getAlias($settings['transcoderPath']);

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

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

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

0 comments on commit c5b81bb

Please sign in to comment.