Skip to content

Commit

Permalink
mob preview, ii
Browse files Browse the repository at this point in the history
  • Loading branch information
alex40724 committed Oct 9, 2023
1 parent 0f064fc commit 51ab60e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Services/MediaObjects/Video/Service/class.GUIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,26 @@ public function handleExtractionRequest(
}
}

protected function checkPreviewPossible(int $mob_id) : bool
{
if ($mob_id === 0) {
return false;
}
$mob = new \ilObjMediaObject($mob_id);
$med = $mob->getMediaItem("Standard");
if (is_object($med)) {
if (\ilFFmpeg::supportsImageExtraction($med->getFormat())) {
return true;
}
}
return false;
}

public function addPreviewInput(\ilPropertyFormGUI $form, int $mob_id = 0) : void
{
if (!$this->checkPreviewPossible($mob_id)) {
return;
}
$lng = $this->domain_service->lng();
$pp = new \ilImageFileInputGUI($lng->txt("mob_preview_picture"), "preview_pic");
$pp->setSuffixes(array("png", "jpeg", "jpg"));
Expand All @@ -122,6 +140,9 @@ public function addPreviewInput(\ilPropertyFormGUI $form, int $mob_id = 0) : voi

public function savePreviewInput(\ilPropertyFormGUI $form, int $mob_id) : void
{
if (!$this->checkPreviewPossible($mob_id)) {
return;
}
$prevpic = $form->getInput("preview_pic");
if ($prevpic["size"] > 0) {
$mob = new \ilObjMediaObject($mob_id);
Expand Down
4 changes: 3 additions & 1 deletion Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ public function initForm(string $a_mode = "create"): void
$this->form_gui->addItem($ta);
}

$this->video_gui->addPreviewInput($this->form_gui, $this->object->getId());
if ($this->object) {
$this->video_gui->addPreviewInput($this->form_gui, $this->object->getId());
}

// standard parameters
if ($a_mode == "edit" &&
Expand Down

0 comments on commit 51ab60e

Please sign in to comment.