Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Controller/VideoFilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,23 @@ public function file() {

// ダウンロード実行
if ($video) {
return $this->Download->doDownload($video['Video']['id']);
//NC2からNC3で移行するとサムネイルが移行されないため、サムネイル画像がないときはNoImageを表示させる
//@see https://github.com/NetCommons3/NetCommons3/issues/1617
try {
$response = $this->Download->doDownload($video['Video']['id']);
} catch (Exception $ex) {
if (!empty($this->request->params['pass']) &&
$this->request->params['pass'][0] === Video::THUMBNAIL_FIELD) {
//NoImageを表示する
$noimagePath = CakePlugin::path('Videos') .
'webroot' . DS . 'img' . DS . 'thumbnail_noimage.png';
$this->response->file($noimagePath, ['name' => 'No Image']);
$response = $this->response;
} else {
throw $ex;
}
}
return $response;
} else {
// 表示できないなら404
throw new NotFoundException(__d('videos', 'Invalid video entry'));
Expand Down
8 changes: 8 additions & 0 deletions Model/Behavior/VideoValidationBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ public function rules(Model $model, $options = array()) {
),
),
));

//NC2からNC3で移行するとサムネイルが移行されないため、サムネイルのupload_idが空であれば、
//エラーにならないようにunsetする。
//@see https://github.com/NetCommons3/NetCommons3/issues/1617
if (isset($model->data['UploadFile']['thumbnail']['id']) &&
! $model->data['UploadFile']['thumbnail']['id']) {
unset($model->data['UploadFile']['thumbnail']);
}
}

return $rules;
Expand Down
Binary file added webroot/img/thumbnail_noimage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.