@@ -111,7 +111,8 @@ public function getVideoUrl($filePath, $videoOptions, $generate = true): string
111111 $ filePath = $ this ->getAssetPath ($ filePath );
112112
113113 if (!empty ($ filePath )) {
114- $ destVideoPath = $ settings ['transcoderPaths ' ]['video ' ] . $ subfolder ?? $ settings ['transcoderPaths ' ]['default ' ];
114+ $ destVideoPath = $ settings ['transcoderPaths ' ]['video ' ] ?? $ settings ['transcoderPaths ' ]['default ' ];
115+ $ destVideoPath .= $ subfolder ;
115116 $ destVideoPath = Craft::parseEnv ($ destVideoPath );
116117 $ videoOptions = $ this ->coalesceOptions ('defaultVideoOptions ' , $ videoOptions );
117118
@@ -205,7 +206,8 @@ public function getVideoUrl($filePath, $videoOptions, $generate = true): string
205206
206207 // If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding
207208 if (file_exists ($ destVideoPath ) && (@filemtime ($ destVideoPath ) >= @filemtime ($ filePath ))) {
208- $ url = $ settings ['transcoderUrls ' ]['video ' ] . $ subfolder ?? $ settings ['transcoderUrls ' ]['default ' ];
209+ $ url = $ settings ['transcoderUrls ' ]['video ' ] ?? $ settings ['transcoderUrls ' ]['default ' ];
210+ $ url .= $ subfolder ;
209211 $ result = Craft::parseEnv ($ url ) . $ destVideoFile ;
210212 // skip encoding
211213 } elseif (!$ generate ) {
@@ -226,7 +228,7 @@ public function getVideoUrl($filePath, $videoOptions, $generate = true): string
226228 /**
227229 * Returns a URL to a video thumbnail
228230 *
229- * @param string $filePath path to the original video or an Asset
231+ * @param Asset| string $filePath path to the original video or an Asset
230232 * @param array $thumbnailOptions of options for the thumbnail
231233 * @param bool $generate whether the thumbnail should be
232234 * generated if it doesn't exists
@@ -248,7 +250,8 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions, $generate = t
248250 $ filePath = $ this ->getAssetPath ($ filePath );
249251
250252 if (!empty ($ filePath )) {
251- $ destThumbnailPath = $ settings ['transcoderPaths ' ]['thumbnail ' ] . $ subfolder ?? $ settings ['transcoderPaths ' ]['default ' ];
253+ $ destThumbnailPath = $ settings ['transcoderPaths ' ]['thumbnail ' ] ?? $ settings ['transcoderPaths ' ]['default ' ];
254+ $ destThumbnailPath .= $ subfolder ;
252255 $ destThumbnailPath = Craft::parseEnv ($ destThumbnailPath );
253256
254257 $ thumbnailOptions = $ this ->coalesceOptions ('defaultThumbnailOptions ' , $ thumbnailOptions );
@@ -308,7 +311,8 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions, $generate = t
308311 if ($ asPath ) {
309312 $ result = $ destThumbnailPath ;
310313 } else {
311- $ url = $ settings ['transcoderUrls ' ]['thumbnail ' ] . $ subfolder ?? $ settings ['transcoderUrls ' ]['default ' ];
314+ $ url = $ settings ['transcoderUrls ' ]['thumbnail ' ] ?? $ settings ['transcoderUrls ' ]['default ' ];
315+ $ url .= $ subfolder ;
312316 $ result = Craft::parseEnv ($ url ) . $ destThumbnailFile ;
313317 }
314318 }
@@ -339,7 +343,8 @@ public function getAudioUrl($filePath, $audioOptions): string
339343 $ filePath = $ this ->getAssetPath ($ filePath );
340344
341345 if (!empty ($ filePath )) {
342- $ destAudioPath = $ settings ['transcoderPaths ' ]['audio ' ] . $ subfolder ?? $ settings ['transcoderPaths ' ]['default ' ];
346+ $ destAudioPath = $ settings ['transcoderPaths ' ]['audio ' ] ?? $ settings ['transcoderPaths ' ]['default ' ];
347+ $ destAudioPath .= $ subfolder ;
343348 $ destAudioPath = Craft::parseEnv ($ destAudioPath );
344349
345350 $ audioOptions = $ this ->coalesceOptions ('defaultAudioOptions ' , $ audioOptions );
@@ -434,15 +439,17 @@ public function getAudioUrl($filePath, $audioOptions): string
434439
435440 // If the audio file already exists and hasn't been modified, return it. Otherwise, start it transcoding
436441 if (file_exists ($ destAudioPath ) && (@filemtime ($ destAudioPath ) >= @filemtime ($ filePath ))) {
437- $ url = $ settings ['transcoderUrls ' ]['audio ' ] . $ subfolder ?? $ settings ['transcoderUrls ' ]['default ' ];
442+ $ url = $ settings ['transcoderUrls ' ]['audio ' ] ?? $ settings ['transcoderUrls ' ]['default ' ];
443+ $ url .= $ subfolder ;
438444 $ result = Craft::parseEnv ($ url ) . $ destAudioFile ;
439445 } else {
440446 // Kick off the transcoding
441447 $ pid = $ this ->executeShellCommand ($ ffmpegCmd );
442448
443449 if ($ synchronous ) {
444450 Craft::info ($ ffmpegCmd , __METHOD__ );
445- $ url = $ settings ['transcoderUrls ' ]['audio ' ] . $ subfolder ?? $ settings ['transcoderUrls ' ]['default ' ];
451+ $ url = $ settings ['transcoderUrls ' ]['audio ' ] ?? $ settings ['transcoderUrls ' ]['default ' ];
452+ $ url .= $ subfolder ;
446453 $ result = Craft::parseEnv ($ url ) . $ destAudioFile ;
447454 } else {
448455 Craft::info ($ ffmpegCmd . "\nffmpeg PID: " . $ pid , __METHOD__ );
@@ -619,13 +626,13 @@ public function handleGetAssetThumbPath(AssetThumbEvent $event)
619626 /**
620627 * Returns a URL to a encoded GIF file (mp4)
621628 *
622- * @param string $filePath path to the original video or an Asset
629+ * @param Asset| string $filePath path to the original video or an Asset
623630 * @param array $gifOptions of options for the GIF file
624631 *
625632 * @return string|false|null URL or path of the GIF file
626633 */
627634
628- public function getGifUrl ($ filePath , $ gifOptions ): string
635+ public function getGifUrl ($ filePath , $ gifOptions )
629636 {
630637 $ result = '' ;
631638 $ settings = Transcoder::$ plugin ->getSettings ();
@@ -640,7 +647,8 @@ public function getGifUrl($filePath, $gifOptions): string
640647
641648 if (!empty ($ filePath )) {
642649 // Dest path
643- $ destVideoPath = $ settings ['transcoderPaths ' ]['gif ' ] . $ subfolder ?? $ settings ['transcoderPaths ' ]['default ' ];
650+ $ destVideoPath = $ settings ['transcoderPaths ' ]['gif ' ] ?? $ settings ['transcoderPaths ' ]['default ' ];
651+ $ destVideoPath .= $ subfolder ;
644652 $ destVideoPath = Craft::parseEnv ($ destVideoPath );
645653
646654 // Options
@@ -696,7 +704,8 @@ public function getGifUrl($filePath, $gifOptions): string
696704
697705 // If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding
698706 if (file_exists ($ destVideoPath ) && (@filemtime ($ destVideoPath ) >= @filemtime ($ filePath ))) {
699- $ url = $ settings ['transcoderUrls ' ]['gif ' ] . $ subfolder ?? $ settings ['transcoderUrls ' ]['default ' ];
707+ $ url = $ settings ['transcoderUrls ' ]['gif ' ] ?? $ settings ['transcoderUrls ' ]['default ' ];
708+ $ url .= $ subfolder ;
700709 $ result = Craft::parseEnv ($ url ) . $ destVideoFile ;
701710 } else {
702711 // Kick off the transcoding
@@ -736,7 +745,7 @@ protected function getFilename($filePath, $options): string
736745
737746 // Add our options to the file name
738747 foreach ($ options as $ key => $ value ) {
739- if (! empty ($ value )) {
748+ if (isset ($ value )) {
740749 $ suffix = '' ;
741750 if (!empty (self ::SUFFIX_MAP [$ key ])) {
742751 $ suffix = self ::SUFFIX_MAP [$ key ];
0 commit comments