Skip to content

Commit a860ae1

Browse files
committed
Only generate a thumbnail when we're actually asked to do so via $generate1
Signed-off-by: Andrew Welch <andrew@nystudio107.com>
1 parent 242d85a commit a860ae1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/services/Transcode.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,15 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions, $generate = t
249249
$ffmpegCmd .= ' -f image2 -y ' . escapeshellarg($destThumbnailPath) . ' >/dev/null 2>/dev/null';
250250

251251
// If the thumbnail file already exists, return it. Otherwise, generate it and return it
252-
if (!file_exists($destThumbnailPath) && $generate) {
253-
$shellOutput = $this->executeShellCommand($ffmpegCmd);
254-
Craft::info($ffmpegCmd, __METHOD__);
252+
if (!file_exists($destThumbnailPath)) {
253+
if ($generate) {
254+
$shellOutput = $this->executeShellCommand($ffmpegCmd);
255+
Craft::info($ffmpegCmd, __METHOD__);
256+
} else {
257+
Craft::info('Thumbnail does not exist, but not asked to generate it: ' . $filePath, __METHOD__);
258+
// The file doesn't exist, and we weren't asked to generate it
259+
return '';
260+
}
255261
}
256262
$result = Craft::getAlias($settings['transcoderUrl']) . $destThumbnailFile;
257263
}

0 commit comments

Comments
 (0)